Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ private struct AutoDictionary<Value> {

// Effectively O(1), worst case O(n)
mutating func insert(_ value: Value) -> UInt64 {
guard storage.count <= UInt64.max else { fatalError("Exceeded maximum storage size") }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is necessary to prevent an infinite loop a few lines down on the while(storage[nextKey] != nil) line.

Since storage.count returns an Int, on 64-bit systems UInt64.max probably won't be reached.

This can be improved but the fatalError is necessary.


var key = salvagedKeys.popLast()
while(key != nil) {
if let key, storage[key] == nil {
Expand Down