[ruby-core:116625] [Ruby master Misc#20222] Dedup-ing clarification
From:
"alanwu (Alan Wu) via ruby-core" <ruby-core@...>
Date:
2024-02-08 01:17:34 UTC
List:
ruby-core #116625
Issue #20222 has been updated by alanwu (Alan Wu).
Seems like a valid optimization to me and is similar to identity of small integers versus heap allocated bignums.
----------------------------------------
Misc #20222: Dedup-ing clarification
https://bugs.ruby-lang.org/issues/20222#change-106635
* Author: kddnewton (Kevin Newton)
* Status: Open
* Priority: Normal
----------------------------------------
``` ruby
source = %q{"foo".freeze.equal?("foo".freeze)}
RubyVM::InstructionSequence.compile(source).eval # => true
RubyVM::InstructionSequence.compile_option = false
RubyVM::InstructionSequence.compile(source).eval # => false
```
`"foo".freeze` uses `opt_str_freeze` when optimizations are turned on, which also deduplicates. This means this code has different behavior depending on if optimizations are turned on or off.
To be clear, I'm not saying whether or not this is a problem. I'm asking if this is desired behavior?
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/