Project

General

Profile

Actions

Feature #17104

closed

Do not freeze interpolated strings when using frozen-string-literal

Added by bughit (bug hit) over 4 years ago. Updated about 4 years ago.

Status:
Closed
Target version:
[ruby-core:99485]

Description

I think the point of frozen string literals is to avoid needless allocations. Interpolated strings are allocated each time, so freezing them appears pointless.

#frozen_string_literal: true

def foo(str)
  "#{str}"
end

fr1 = 'a'
fr2 = 'a'
fr1_1 = foo(fr1)
fr2_1 = foo(fr2)

puts fr1.__id__, fr2.__id__, fr1_1.__id__, fr2_1.__id__

puts fr1_1 << 'b'

Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Misc #16047: Reconsider impact of frozen_string_literal on dynamic stringsClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0