Clean KeyedCollectionSlim.RemoveFirst method#3877
Merged
Conversation
Jim8y
reviewed
Apr 5, 2025
| var (_, time) = pendingKnownHashes.First; | ||
| if (oneMinuteAgo <= time) break; | ||
| pendingKnownHashes.RemoveFirst(); | ||
| if (!pendingKnownHashes.RemoveFirst()) break; |
Contributor
There was a problem hiding this comment.
is this really necessary? looks like it will end the loop anyway.
Member
Author
There was a problem hiding this comment.
Just use the return value instead of drop it
Member
There was a problem hiding this comment.
this is minor as Jimmy said.
Loop would be end anyway I think
KeyedCollectionSlimKeyedCollectionSlim.RemoveFirst method
Contributor
There was a problem hiding this comment.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/Neo.IO/Caching/KeyedCollectionSlim.cs:28
- Changing the GetKeyForItem parameter from TItem? to TItem requires ensuring that all subclass implementations guarantee a non-null item before calling this method.
protected abstract TKey GetKeyForItem(TItem item);
tests/Neo.UnitTests/IO/Caching/UT_KeyedCollectionSlim.cs:80
- [nitpick] Consider adding a test case for when the collection is empty to verify that RemoveFirst returns false.
Assert.IsTrue(collection.RemoveFirst());
vncoelho
reviewed
Apr 9, 2025
| private void OnTimer() | ||
| { | ||
| DateTime oneMinuteAgo = TimeProvider.Current.UtcNow.AddMinutes(-1); | ||
| var oneMinuteAgo = TimeProvider.Current.UtcNow.AddMinutes(-1); |
Member
There was a problem hiding this comment.
this is still quite empirically calibrated. I remember when this was added.
We need to improve this logic at all.
Wi1l-B0t
approved these changes
Apr 17, 2025
Jim8y
approved these changes
Apr 17, 2025
Jim8y
added a commit
to Jim8y/neo
that referenced
this pull request
Apr 17, 2025
* master: DBFTPlugin: include consensus time into block interval (neo-project#3900) Isolate unit tests (neo-project#3904) Use DateTime.UtcNow (neo-project#3902) Update workflow (neo-project#3901) optimize: show state more readable (neo-project#3899) Optimize KeyedCollectionSlim (neo-project#3877) Native: move MillisecondsPerBlock setting to native Policy (neo-project#3895) optimize: history command support (neo-project#3892) Ensure that view interops can't be changed outside (neo-project#3812)
cschuchardt88
pushed a commit
to cschuchardt88/neo
that referenced
this pull request
Jun 8, 2025
Co-authored-by: Jimmy <jinghui@wayne.edu> Co-authored-by: Will <201105916+Wi1l-B0t@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
An small optimization of
KeyedCollectionSlimType of change
How Has This Been Tested?
RemoveFirst_ShouldRemoveFirstItemTest Configuration:
Checklist: