From a367373fe3e9fd405bb11b0eafb7b74865d884ad Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Sat, 16 Nov 2019 19:47:31 +0900 Subject: Revert "Implement Ruby2.7's frozen strings from `Symbol#to_s`" This feature was reverted from Ruby 2.7. --- mrbgems/mruby-class-ext/src/class.c | 6 +++++- mrbgems/mruby-symbol-ext/mrblib/symbol.rb | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'mrbgems') diff --git a/mrbgems/mruby-class-ext/src/class.c b/mrbgems/mruby-class-ext/src/class.c index 0d27c30ed..02ebf80cc 100644 --- a/mrbgems/mruby-class-ext/src/class.c +++ b/mrbgems/mruby-class-ext/src/class.c @@ -5,7 +5,11 @@ static mrb_value mrb_mod_name(mrb_state *mrb, mrb_value self) { - return mrb_class_path(mrb, mrb_class_ptr(self)); + mrb_value name = mrb_class_path(mrb, mrb_class_ptr(self)); + if (mrb_string_p(name)) { + MRB_SET_FROZEN_FLAG(mrb_basic_ptr(name)); + } + return name; } static mrb_value diff --git a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb index 4b4cf83fe..99fa275d5 100644 --- a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb +++ b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb @@ -10,7 +10,7 @@ class Symbol # Same as sym.to_s.capitalize.intern. def capitalize - self.to_s.capitalize.to_sym + (self.to_s.capitalize! || self).to_sym end ## @@ -20,7 +20,7 @@ class Symbol # Same as sym.to_s.downcase.intern. def downcase - self.to_s.downcase.to_sym + (self.to_s.downcase! || self).to_sym end ## @@ -30,7 +30,7 @@ class Symbol # Same as sym.to_s.upcase.intern. def upcase - self.to_s.upcase.to_sym + (self.to_s.upcase! || self).to_sym end ## @@ -41,7 +41,7 @@ class Symbol def casecmp(other) return nil unless other.kind_of?(Symbol) - lhs = self.to_s.upcase + lhs = self.to_s; lhs.upcase! rhs = other.to_s.upcase lhs <=> rhs end -- cgit v1.2.3