From 1633469e9c881003caa1589a12b3592289df8901 Mon Sep 17 00:00:00 2001 From: take_cheeze Date: Fri, 20 Jun 2014 22:07:44 +0900 Subject: Reduce string creation in `Symbol#casecmp` by using `case!`. --- mrbgems/mruby-symbol-ext/mrblib/symbol.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb index 1e249c281..acb2a562c 100644 --- a/mrbgems/mruby-symbol-ext/mrblib/symbol.rb +++ b/mrbgems/mruby-symbol-ext/mrblib/symbol.rb @@ -45,7 +45,9 @@ class Symbol def casecmp(other) return nil unless other.kind_of?(Symbol) - self.to_s.upcase <=> other.to_s.upcase + lhs = self.to_s; lhs.upcase! + rhs = other.to_s; rhs.upcase! + lhs <=> rhs end # -- cgit v1.2.3