From: Tom Hughes Date: Tue, 18 Feb 2025 20:14:01 +0000 (+0000) Subject: Avoid modifying constant strings X-Git-Tag: live~94 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/881d0b11b519524873ec28ea9ca8010b5710c83b?hp=--cc Avoid modifying constant strings This fixes a ruby 3.4 warning about strings that will be frozen by default in a future release. --- 881d0b11b519524873ec28ea9ca8010b5710c83b diff --git a/lib/rich_text.rb b/lib/rich_text.rb index bdf9c37ca..f38de7621 100644 --- a/lib/rich_text.rb +++ b/lib/rich_text.rb @@ -144,7 +144,7 @@ module RichText end def truncated_text_content(element) - text = "" + text = String.new append_text = lambda do |child| if child.type == :text diff --git a/lib/short_link.rb b/lib/short_link.rb index 8983f3bd3..2dfb0fb58 100644 --- a/lib/short_link.rb +++ b/lib/short_link.rb @@ -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|