mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 19:30:29 +00:00
Refactor peer list calculation
This commit is contained in:
parent
c5ee9dc123
commit
dd06922e85
@ -502,10 +502,30 @@ public final class StorageBox {
|
|||||||
|
|
||||||
self.valueBox.begin()
|
self.valueBox.begin()
|
||||||
|
|
||||||
self.valueBox.scan(self.peerIdToIdTable, keys: { key in
|
var fromKey = ValueBoxKey(length: 8)
|
||||||
result.append(PeerId(key.getInt64(0)))
|
fromKey.setInt64(0, value: 0)
|
||||||
return true
|
|
||||||
})
|
let toKey = ValueBoxKey(length: 8)
|
||||||
|
toKey.setInt64(0, value: Int64.max)
|
||||||
|
|
||||||
|
while true {
|
||||||
|
var peerId: Int64?
|
||||||
|
self.valueBox.range(self.peerIdToIdTable, start: fromKey, end: toKey, keys: { key in
|
||||||
|
peerId = key.getInt64(0)
|
||||||
|
return false
|
||||||
|
}, limit: 1)
|
||||||
|
|
||||||
|
if let peerId = peerId {
|
||||||
|
if peerId != 0 {
|
||||||
|
result.append(PeerId(peerId))
|
||||||
|
}
|
||||||
|
|
||||||
|
fromKey.setInt64(0, value: peerId)
|
||||||
|
fromKey = fromKey.successor
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.valueBox.commit()
|
self.valueBox.commit()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user