On Tue, Sep 26, 2006 at 05:00:17AM +0900, Christian Neukirchen wrote:
> James Edward Gray II <james / grayproductions.net> writes:
> 
> > On Sep 25, 2006, at 12:03 PM, Rich Morin wrote:
> >
> >> Use '' by default:
> >>
> >>   -  It's less work for the interpreter.
> >
> > What makes you say this?
> >
> > #!/usr/bin/env ruby -w
> >
> > require "benchmark"
> >
> > TESTS = 1_000_000
> > Benchmark.bmbm(10) do |results|
> >   results.report("double:") { TESTS.times { "James" } }
> >   results.report("single:") { TESTS.times { 'James' } }
> > end
> 
> You really should compare the parse-trees of these before even trying
> to benchmark it that way...
> 
In the non-interpolation case the parse-trees are identical:

% cat strings.rb
f('James', "James")

% cat strings.rb | parse_tree_show -f
[[:fcall, :f, [:array, [:str, "James"], [:str, "James"]]]]
> > James Edward Gray II
> -- 
> Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org