-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[XABT] Replace SortedSet with HashSet. #9280
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok.
I do wonder if there is a faster way to do this. We just need to know if templateState and state have identical data.
Using the current code we loop throught the lists at least 4 times
2 to create the hashsets.
The two more when we do the comparisons (luckily we use the fast path in this case because they have the same item count and the same comparer).
I wonder if it would be better to generate a hash of each set and compare that, but the items would need to be processed in order for that to work.
Using a running hash or checksum might not be accurate enough, as the integer types we'd use for them have limited range. However, what I think might speed things up a little bit more is not using LINQ to populate the |
For the If anything, we could probably omit this step for a Debug build. It is largely just ensuring that something that "can't happen" isn't happening. It's probably safe to skip this for Debug and only do it on Release builds. But that's a bigger change... |
Yeah, it's a good idea to omit it for Debug, the assemblies there should be identical. |
One question that came up with #9208 was "why
SortedSet
instead ofHashSet
"?Indeed a
HashSet
seems to be 10ms - 15ms faster to construct than theSortedSet
while taking the same ~1ms to perform theSetEquals
operation.