Repository navigation
Hashery 2.2.0: faster LRUHash, bug fixes, modernized project - #27
Merged
Merged
Conversation
Parenthesize ambiguous splat and block arguments, fix a mismatched indentation and drop an unused variable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build strings from unfrozen buffers so FuzzyHash and IniHash keep working when string literals are frozen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StaticHash subclasses CRUDHash but never required it, so loading hashery/static_hash by itself raised NameError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IniHash.new(hash) passed a nil path to FileTest.readable_real? and raised TypeError, which also broke IniHash.text and write_to_file. write_to_file with a comment called String#each, gone since Ruby 1.9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep entries in a plain Hash ordered from least to most recently used, promoting an entry by deleting and re-inserting it, instead of a linked list of Struct nodes. This is about twice as fast on Ruby 2.7 through 4.0. The public API is unchanged, and randomized differential tests against the 2.1.2 implementation show identical results, iteration order, evictions and release_proc calls. Also fixes and Hash-compatible additions: * dup and clone no longer share state with the original. * inspect and to_s show keys and values like Hash#inspect, and no longer mutate a string literal. * keys and values list most recently used first, matching each. * fetch accepts a default argument; its KeyError names the key. * delete takes a block for missing keys. * delete_if returns an Enumerator without a block. * Add length. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Indexer exporter could not set required_ruby_version. Use a plain gemspec instead, now requiring Ruby 2.7 or newer, with the version in lib/hashery/version.rb (bumped to 2.2.0; Hashery::VERSION still said 2.1.0). The gem keeps the same files and require_paths as 2.1.2, minus the Indexer metadata. The Gemfile now uses the gemspec, and the Rakefile gains bundler's gem tasks and a default task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the unit tests and demos on Ruby 2.7 through 4.0, plus the demos with frozen string literals enabled on 4.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an LRUHash section, note the Ruby 2.7 requirement, describe running the tests with Bundler, use https and the github.io homepage, and drop the dead Travis, Gittip and freenode links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <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.
Almost all of hashery's downloads come from pdf-reader, which loads
hashery/lru_hashand pinshashery ~> 2.0. So this release concentrates on LRUHash and keeps it fully compatible: a 2.2.0 reaches every pdf-reader user automatically.LRUHash
release_proccall matched. A planted bug was caught, so the check works.dupandcloneshared internal state with the original, so writing to a copy corrupted it.inspectandto_sprinted keys and values withto_s({=>1, a=>x}) and fail when frozen string literals are enabled.fetch(key, default), aKeyErrorthat names the key,delete(key) { ... },delete_ifwithout a block returns an Enumerator, andlength.keysandvaluesnow list most recently used first, matchingeach. Before, they came out roughly in insertion order.Other fixes
IniHash.new(hash)raised a TypeError, which brokeIniHash.textandIniHash.write_to_file.write_to_filewith a comment also calledString#each, gone since Ruby 1.9.require 'hashery/static_hash'failed when loaded on its own.ruby -w, and no mutation of string literals.Project
hashery.gemspecreplaces the Indexer metadata (.gemspec,.index,Index.yml,Assembly,MANIFEST,lib/hashery.yml). It requires Ruby 2.7 or newer and gets its version fromlib/hashery/version.rb, now 2.2.0. The built gem ships the same files andrequire_pathsas 2.1.2, minus the Indexer metadata.Testing
hashery.gemspecinstalls and loads on 2.7 and 4.0.d7a9ec6, Ruby 3.4.9) gives 2274 examples, 0 failures, 6 pending against both 2.1.2 and this branch, with the same 6 pending.Saved for a 3.0
These would change behavior, so they're left out here:
has_value?comparing with==like Hash,LRUHash#==and#to_hash, and sensible behavior for a frozen LRUHash.🤖 Generated with Claude Code