aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/object.go19
-rw-r--r--repository.go2
2 files changed, 15 insertions, 6 deletions
diff --git a/core/object.go b/core/object.go
index 2c41245..9b6e56d 100644
--- a/core/object.go
+++ b/core/object.go
@@ -21,7 +21,7 @@ type ObjectStorage interface {
New() Object
Set(Object) Hash
Get(Hash) (Object, bool)
- IterType(ObjectType) ObjectIter
+ Iter(ObjectType) ObjectIter
}
// ObjectType internal object type's
@@ -59,8 +59,13 @@ type ObjectIter interface {
Close()
}
-// ObjectLookupIter yields a series of objects by retrieving each one from
-// object storage.
+// ObjectLookupIter implements ObjectIter. It iterates over a series of object
+// hashes and yields their associated objects by retrieving each one from
+// object storage. The retrievals are lazy and only occur when the iterator
+// moves forward with a call to Next().
+//
+// The ObjectLookupIter must be closed with a call to Close() when it is no
+// longer needed.
type ObjectLookupIter struct {
storage ObjectStorage
series []Hash
@@ -99,7 +104,11 @@ func (iter *ObjectLookupIter) Close() {
iter.pos = len(iter.series)
}
-// ObjectSliceIter yields a series of objects from a slice of objects.
+// ObjectSliceIter implements ObjectIter. It iterates over a series of objects
+// stored in a slice and yields each one in turn when Next() is called.
+//
+// The ObjectSliceIter must be closed with a call to Close() when it is no
+// longer needed.
type ObjectSliceIter struct {
series []Object
pos int
@@ -189,7 +198,7 @@ func (o *RAWObjectStorage) Get(h Hash) (Object, bool) {
return obj, ok
}
-func (o *RAWObjectStorage) IterType(t ObjectType) ObjectIter {
+func (o *RAWObjectStorage) Iter(t ObjectType) ObjectIter {
var series []Object
switch t {
case CommitObject:
diff --git a/repository.go b/repository.go
index 31e5fc7..d0bc103 100644
--- a/repository.go
+++ b/repository.go
@@ -100,7 +100,7 @@ func (r *Repository) Commit(h core.Hash) (*Commit, error) {
// Commits decode the objects into commits
func (r *Repository) Commits() *CommitIter {
- return NewCommitIter(r, r.Storage.IterType(core.CommitObject))
+ return NewCommitIter(r, r.Storage.Iter(core.CommitObject))
}
// Tree return the tree with the given hash