-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Remove redundant memory usage in Checkpoints #4540
Conversation
🦋 Changeset detectedLatest commit: 6ad3f63 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@Amxx (I apologize for the tagging, this is originally your code, judging by the Git Blame) I'm very interested in why the library relies on non-strictly increasing order everywhere, like here:
Based on the descriptions of the functions, it looks like they were created with the expectation that there may be elements with the same keys:
At the same time, the insertion implementation does not allow adding multiple elements with the same key. This, of course, can be done manually by forcibly adding an element to the array. But you can also add an incorrect element (with a decreasing key) in such way. So it doesn't look like there should be multiple elements with the same key in an array in normal use of the library. If the array is strictly ordered, then it is strange that the search does not handle the case when it hits the desired key (the case of equality). In the worst case, if the array is N long and the target is exactly in the middle, the current implementation will do something like So with simple example like (keys) I'm interested if there's a reason not to make such changes. UPD: created a separate PR for this question: #4544 |
That is an interresting question. We always try to be on the safe(r) side. Given that the simplest version of the code (the one that doesn't handle equality) is the safest (it works with more structure) it felt like the better option. Now, it may reasonable to assume that this will only be used with structures produced using @frangio WDYT? |
3c2cb18
to
03d713e
Compare
force-pushed: removed unchecked blocks for safe arithmetic, since this is a standalone change and would probably be better done in another pull request |
Created a separate pull request for this question: |
@frangio Do we merge that for 5.0, or is 5.0 frozen and that goes into 5.1? |
I would put this in the bin for 5.1 with other optimizations we haven't merged yet. |
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.
LGTM, will wait on @Amxx since a couple of changes were made after 5.0
Some optimizations, as i wrote in #4512 (comment)
Fixes LIB-1187
npx changeset add
)