Hey, just wondering if this is a common thing in normal Ruby
code. I think it's somewhat common to use symbols and integers
in string interpolation; at least I seem to do it 
Anyways, I just posted a new patch to ruby-core and am wondering
if there's more Rubyists here which might find it useful for 2.5:
https://bugs.ruby-lang.org/issues/13715
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/81905
https://public-inbox.org/ruby-core/redmine.issue-13715.20170704220431.8a8b5cc25b8ecd8e@ruby-lang.org/
Even without the special case for Symbols, the inline caching
seems to be a decent win for other types.
Yes, definitely. As a general rule, if I have all the data ahead of
time I always* use interpolation to create strings. If the data is
streamed then I'll choose how I stringify them based on other factors
(shared references, frozenness, number of elements, likelihood and
impact of reallocations vs whole new allocations, readability, etc.)
* except when I don't.
It doesn't help that `<<` and `+` both need me to explicitly `.to_s`
any parameter that doesn't respond_to? :to_str (a feature for bug
detection, but a hindrance for writing quickly)
Optimisation is never my primary driver when writing Ruby (except for
broad strokes, like choosing appropriate data structures and
algorithms) but if you can make my code run faster then I certainly
won't complain.
Cheers
···
On 5 July 2017 at 08:14, Eric Wong <e@80x24.org> wrote:
Hey, just wondering if this is a common thing in normal Ruby
code. I think it's somewhat common to use symbols and integers
in string interpolation; at least I seem to do it 
Anyways, I just posted a new patch to ruby-core and am wondering
if there's more Rubyists here which might find it useful for 2.5:
Feature #13715: [PATCH] avoid garbage from Symbol#to_s in interpolation - Ruby master - Ruby Issue Tracking System
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/81905
[ruby-core:81905] [Ruby trunk Feature#13715] [PATCH] avoid garbage from Symbol#to_s in interpolation - normalperson
Even without the special case for Symbols, the inline caching
seems to be a decent win for other types.
--
Matthew Kerwin
http://matthew.kerwin.net.au/