Small improvements, part 2#65
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Bumps the version to 10.0.alpha14 and applies two collection-level improvements: a new tryTrimTo(int) API on UnsafeMutableArray for safe storage shrinking, and pervasive early-exit isEmpty() short-circuits across the three hash-based dictionary implementations to avoid unnecessary allocations and iterations. Also adds a new .github/skills/generate-branch-summary.md skill doc and a "Collections optimization pattern" section to the Copilot instructions.
Changes:
- Add
UnsafeMutableArray.tryTrimTo(int)and implement it inAbstractMutableArray. - Add
isEmpty()fast paths toiterator(),keys(...)andvalues(...)overloads in the Int/Long/Ref hash dictionaries. - Bump
rootProject.versionand README example version from10.0.alpha13→10.0.alpha14; add Copilot/skill documentation.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| rlib-collections/src/main/java/javasabr/rlib/collections/array/UnsafeMutableArray.java | Adds new tryTrimTo(int) interface method with javadoc. |
| rlib-collections/src/main/java/javasabr/rlib/collections/array/impl/AbstractMutableArray.java | Implements tryTrimTo with capacity/size validation. |
| rlib-collections/src/main/java/javasabr/rlib/collections/dictionary/impl/AbstractHashBasedIntToRefDictionary.java | Adds early-exit isEmpty() checks in iterator/keys/values overloads. |
| rlib-collections/src/main/java/javasabr/rlib/collections/dictionary/impl/AbstractHashBasedLongToRefDictionary.java | Same isEmpty short-circuits for the long-keyed variant. |
| rlib-collections/src/main/java/javasabr/rlib/collections/dictionary/impl/AbstractHashBasedRefToRefDictionary.java | Same isEmpty short-circuits for the ref-keyed variant. |
| build.gradle | Version bump to 10.0.alpha14. |
| README.md | Updates the example rlibVersion to 10.0.alpha14. |
| .github/copilot-instructions.md | Documents the new collections optimization pattern. |
| .github/skills/generate-branch-summary.md | New skill describing how to generate a branch summary. |
|
|
|
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.
Changes Summary
1. New Array API:
tryTrimTo(int)UnsafeMutableArray.tryTrimTo(int internalStorageSize)method to safely resize internal storageAbstractMutableArraywith validation logic:@since 10.0.alpha14tag2. Collection Optimization Pattern
Applied early-exit
isEmpty()checks across dictionary implementations to avoid unnecessary allocations and iterations:Methods optimized include:
iterator()— returns empty iterator immediatelykeys()(all overloads) — returns empty arrays/containersvalues()(all overloads) — returns empty arrays/containers3. Documentation
tryTrimTo()method.github/copilot-instructions.mdwith "Collections optimization pattern" sectionTesting & Validation
./gradlew :rlib-collections:build✅./gradlew clean build(recommended before merge)