Do you know if using double quotes instead of single quotes in ruby decreases performance in any meaningful way in ruby 1.8 and 1.9.
so if I type
qu
There is no significant difference in either direction. It would have to be huge for it to matter.
Except for times when you are sure that there is an actual problem with timing, optimize for programmer maintainability.
The costs of machine time are very very small. The costs of programmer time to write code and maintain it is huge.
What good is an optimization to save seconds, even minutes of runtime over thousands of runs if it means that the code is harder to maintain?
Pick with a style and stick with it but do not pick that style based on statistically insignificant milliseconds of runtime.
Single quotes can be very slightly faster than double quotes because the lexer doesn't have to check for #{}
interpolation markers. Depending on implementation, etc. Note that this is a parse-time cost, not a run-time cost.
That said, the actual question was whether using double quoted strings "decreases performance in any meaningful way", to which the answer is a decisive "no". The difference in performance is so incredibly small that it is completely insignificant compared to any real performance concerns. Don't waste your time.
Actual interpolation is a different story, of course. 'foo'
will be almost exactly 1 second faster than "#{sleep 1; nil}foo"
.