ndb: fix iterators, pack id tags, more tests

This commit is contained in:
William Casarin
2023-07-23 11:55:36 -07:00
parent 1a33d639ed
commit e34351ca37
10 changed files with 401 additions and 176 deletions

View File

@@ -16,9 +16,7 @@ struct TagSequence: Sequence {
}
subscript(index: Int) -> NdbTagElem? {
if index >= tag.pointee.count {
return nil
}
guard index < count else { return nil }
return NdbTagElem(note: note, tag: tag, index: Int32(index))
}
@@ -40,14 +38,6 @@ struct TagIterator: IteratorProtocol {
return el
}
subscript(index: Int) -> NdbTagElem? {
if index >= tag.pointee.count {
return nil
}
return NdbTagElem(note: note, tag: tag, index: Int32(index))
}
var index: Int32
let note: NdbNote
var tag: UnsafeMutablePointer<ndb_tag>
@@ -62,10 +52,3 @@ struct TagIterator: IteratorProtocol {
self.index = 0
}
}
func ndb_maybe_pointee<T>(_ p: UnsafeMutablePointer<T>!) -> T? {
guard p != nil else { return nil }
return p.pointee
}