Project

General

Profile

Feature #26561

Updated by Toshi MARUYAMA over 7 years ago

Hi, Ruby 2.3 introduced support for frozen string literals 

 Pros 
 <pre> 
 * less memory consumption 
 * performance (less GC preasure) 
 * safer code 


 
 </pre> 

 Cons 
 <pre> 
 * mutable functions like force_encoding or gsub! can't be called on frozen strings anymore, this may cause incompatibility with some plugins, but it's very easy to fix and still maintain the backwards compatibility 
 * a magic comment has to be added at the top of each rb file :-( 
 </pre> 

 More information 
 https://www.pluralsight.com/blog/software-development/ruby-2-3--working-with-immutable-strings- 

 Many popular gems and libraries already did this - for example: 
 https://github.com/rails/rails/pull/29655 
 https://github.com/mikel/mail/pull/970 

 I attached a patch based on master that passes all tests. 
 There're some garbage changes like removed whitespaces, I'll clean it up if it's approved. 

 What do you think? 

Back