Skip to content
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

Avoid binary search over potentially unsorted data #2247

Merged
merged 6 commits into from
Apr 20, 2023

Conversation

notlesh
Copy link
Contributor

@notlesh notlesh commented Apr 19, 2023

What does it do?

Tracks can potentially be unsorted, so we don't want to perform a binary_search_by_key() on it. Instead, we do an linear search.

The performance impact depends on the number of tracks. Assuming there aren't a lot of tracks, I suspect that find() performs as well as or better than binary_search anyway.

@notlesh notlesh added B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit not-breaking Does not need to be mentioned in breaking changes labels Apr 19, 2023
@crystalin crystalin mentioned this pull request Apr 19, 2023
15 tasks
@librelois librelois merged commit aaf9e0f into master Apr 20, 2023
@librelois librelois deleted the notlesh-dont-assume-sorted-vec branch April 20, 2023 12:02
librelois pushed a commit that referenced this pull request Apr 20, 2023
* Avoid binary search over potentially unsorted data

* Slight improvement in regression test

* Err, this is how you would test empty vec...

* Better test

* Toml sort

---------

Co-authored-by: crystalin <alan.sapede@gmail.com>
imstar15 pushed a commit to AvaProtocol/moonbeam that referenced this pull request May 16, 2023
…on#2247)

* Avoid binary search over potentially unsorted data

* Slight improvement in regression test

* Err, this is how you would test empty vec...

* Better test

* Toml sort

---------

Co-authored-by: crystalin <alan.sapede@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit not-breaking Does not need to be mentioned in breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants