]> git.openstreetmap.org Git - rails.git/blobdiff - lib/short_link.rb
Avoid modifying constant strings
[rails.git] / lib / short_link.rb
index 8983f3bd3bd1c4858d5aab8caa57a538d12b32a7..2dfb0fb582baa1578b7710ced01b89b218fd17fd 100644 (file)
@@ -23,7 +23,7 @@ module ShortLink
       # keep support for old shortlinks which use the @ character, now
       # replaced by the ~ character because twitter is horribly broken
       # and we can't have that.
-      str.tr!("@", "~")
+      str = str.tr("@", "~")
 
       str.each_char do |c|
         t = ARRAY.index c
@@ -57,7 +57,7 @@ module ShortLink
     def encode(lon, lat, z)
       code = interleave_bits(((lon + 180.0) * (2**32) / 360.0).to_i,
                              ((lat + 90.0) * (2**32) / 180.0).to_i)
-      str = ""
+      str = String.new
       # add eight to the zoom level, which approximates an accuracy of
       # one pixel in a tile.
       ((z + 8) / 3.0).ceil.times do |i|