Skip to content

Remove dead, useless storage count check#1647

Open
SiliconA-Z wants to merge 1 commit intoswiftlang:mainfrom
SiliconA-Z:Remove-dead-code
Open

Remove dead, useless storage count check#1647
SiliconA-Z wants to merge 1 commit intoswiftlang:mainfrom
SiliconA-Z:Remove-dead-code

Conversation

@SiliconA-Z
Copy link
Copy Markdown
Contributor

Storage count is always equal to or less than the max, so this is useless dead code.

Storage count is always equal to or less than the max, so this is useless dead code.
@itingliu itingliu requested a review from cthielen January 13, 2026 22:46
@itingliu
Copy link
Copy Markdown
Contributor

@swift-ci please test


// 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.

Copy link
Copy Markdown
Contributor

@cthielen cthielen left a comment

Choose a reason for hiding this comment

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

See comment about why the check is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants