Is there a performance gain in using single quotes vs double quotes in ruby?

前端 未结 14 681
挽巷
挽巷 2020-11-27 10:32

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         


        
14条回答
  •  借酒劲吻你
    2020-11-27 11:09

    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.

提交回复
热议问题