Project

General

Profile

Misc #14000

OpenStruct with #frozen_string_literal: true

Added by esparta (Espartaco Palma) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
[ruby-core:83203]

Description

The current implementation of OpenStruct needs minimal changes in order to support frozen strings.
The mutable strings are only on inspect method.

IMO, we have two options:

a) leave the code as it is and just adding .dup where is needed
b) Change to a functional style (map + join) instead of flags + concat.

Associated revisions

Revision e565c838
Added by marcandre (Marc-Andre Lafortune) over 1 year ago

lib/ostruct.rb: Use frozen literals.

Patch adapted from Espartaco Palma. [GH-1714] [Bug #14000]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 60406
Added by marcandre (Marc-Andre Lafortune) over 1 year ago

lib/ostruct.rb: Use frozen literals.

Patch adapted from Espartaco Palma. [GH-1714] [Bug #14000]

Revision 60406
Added by marcandre (Marc-Andre Lafortune) over 1 year ago

lib/ostruct.rb: Use frozen literals.

Patch adapted from Espartaco Palma. [GH-1714] [Bug #14000]

Revision 60406
Added by marcandre (Marc-Andre Lafortune) over 1 year ago

lib/ostruct.rb: Use frozen literals.

Patch adapted from Espartaco Palma. [GH-1714] [Bug #14000]

History

Updated by duerst (Martin Dürst) over 1 year ago

Thanks for looking at where we can use #frozen_string_literal: true.

I think it's good to try this, but #frozen_string_literal: true should not be used as a cargo cult. So it would be good to know whether your patch leads to some/any speedups or not, or some other improvements.

Updated by k0kubun (Takashi Kokubun) over 1 year ago

  • Assignee set to marcandre (Marc-Andre Lafortune)
#4

Updated by marcandre (Marc-Andre Lafortune) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset trunk|r60406.


lib/ostruct.rb: Use frozen literals.

Patch adapted from Espartaco Palma. [GH-1714] [Bug #14000]

Also available in: Atom PDF