Skip to content

Stop retaining the unused original options hash - #27

Open
OskarEichler wants to merge 1 commit into
apotonick:masterfrom
OskarEichler:codex/release-unused-options
Open

Stop retaining the unused original options hash#27
OskarEichler wants to merge 1 commit into
apotonick:masterfrom
OskarEichler:codex/release-unused-options

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Remove the unused @static reference in Uber::Options#initialize. Since 0.1.0, every entry is already wrapped and stored in the Options hash; nothing reads @static. Retaining the caller's entire original Hash is unnecessary and can keep subsequently removed entries alive.

Reproduction

require 'uber/options'
require 'weakref'
def sample
  input = {payload: Object.new}
  [Uber::Options.new(input), WeakRef.new(input)]
end
options, reference = sample
3.times { GC.start }
p !!reference.weakref_alive?
p options.evaluate(nil).keys

Original: true, [:payload]. Fixed: false, [:payload]. Required wrapped values remain reachable, while the original input Hash can be collected.

Verification

  • Existing baseline and this isolated branch: bundle exec rake test, 45 tests / 50 assertions, zero failures/errors/skips on Ruby 4.0.6 / Minitest 4.7.5.
  • 1,000 focused checks on Ruby 3.2.11 and 4.0.6: 250 frozen source hashes become collectable, evaluated values remain correct, repeated results remain independent, and Options Hash mutation works.
  • Release-based combination with the separate keyword-forwarding fix passes the existing 45-test suite on both Rubies, 4,202 forwarding checks and 2,750 inheritance/delegation boundary checks. All eight runtime files compile; package retains 25 paths and unchanged compared metadata. Two existing Lint offenses unchanged.
  • Downstream Representable 3.2.0 baseline/fixed each pass 544 tests / 700 assertions, zero failures/errors and three existing skips on Ruby 3.2.11. Ruby 4 has the same eight legacy inspection-format failures, zero errors and three skips. Existing tests/expectations are unchanged; external tooling supplies the legacy MiniTest alias and profiler API.

Compatibility / limitations

No documented API breaking change intended. The undocumented, unused @static instance variable no longer exists; reflective code relying on it would be affected. This deliberately does not deep-copy or change the wrapped values or result Hash behavior. The older #17 static-result aliasing proposal addresses a different, superseded implementation.

No new/modified checked-in tests. Ruby 1.9.3–3.1, JRuby, Windows and Linux were not run locally. Collection evidence is from CRuby WeakRef/GC checks; no production memory-size or throughput claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant