assume native ordered hashes; drop legacy Ordering module (v9.0.0)#30
Open
ahoward wants to merge 1 commit into
Open
assume native ordered hashes; drop legacy Ordering module (v9.0.0)#30ahoward wants to merge 1 commit into
ahoward wants to merge 1 commit into
Conversation
Ruby 1.9+ preserves Hash insertion order natively, and the gem already requires Ruby >= 3.0 — so the manual @keys bookkeeping is dead weight. Remove it: - delete lib/map/ordering.rb (the @keys array + allocate/[]=/keys/each/delete/ shift/unshift/push/pop overrides) and its conditional include - promote the native-Hash implementations (previously guarded by `unless RUBY_VERSION < '1.9' || ENV['MAP_FORCE_ORDERING']`) to unconditional defs - drop the MAP_FORCE_ORDERING env knob and the test:with/without_ordering rake tasks - scrub the stale "moved to Map::Ordering" comments No behavior change on any supported Ruby: order flows from Hash#keys/#each everywhere (==, <=>, to_hash, iterators). One documented note: `push` of an existing key keeps its position (native []=), rather than moving it to the end as the legacy @keys path did — untested either way; native is now canonical. test/map_test.rb: 56 tests, 4940 assertions, 100% green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
Ruby 1.9+ preserves
Hashinsertion order natively, andmapalready requires Ruby>= 3.0. So the manual@keysbookkeeping (recently extracted toMap::Orderingfor the dead Ruby-<1.9 path) is pure dead weight. This removes it and letsMaprideHash's native ordering.changes
lib/map/ordering.rb— the@keysarray plus theallocate/[]=/keys/each*/delete/shift/unshift/push/popoverrides, and its conditionalinclude.unless RUBY_VERSION < '1.9' || ENV['MAP_FORCE_ORDERING']to unconditional defs.MAP_FORCE_ORDERINGknob and thetest:with_ordering/test:without_orderingrake tasks (no second path left).Map::Ordering" comments.Net:
lib/map.rb−65 lines,ordering.rb−126, Rakefile −18.behavior
No change on any supported Ruby — order flows from
Hash#keys/#eacheverywhere (==,<=>,to_hash, all iterators). One documented note:pushof an already-present key now keeps its position (native[]=) instead of moving it to the end as the legacy@keyspath did. Untested either way; native is now canonical.tests
ruby -w -I ./lib -I ./test/lib test/map_test.rb→ 56 tests, 4940 assertions, 100% passed.Version bump to
9.0.0is a proposal — drop to8.1.0if you'd rather treat this as internal-only.🤖 Generated with Claude Code