ruby-changes:46426
From: duerst <ko1@a...>
Date: Tue, 2 May 2017 14:15:10 +0900 (JST)
Subject: [ruby-changes:46426] duerst:r58537 (trunk): rework definition of String#unicode_normalize
duerst 2017-05-02 14:15:04 +0900 (Tue, 02 May 2017) New Revision: 58537 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58537 Log: rework definition of String#unicode_normalize simplify String#unicode_normalize in lib/unicode_normalize.rb by redefining it in lib/unicode_normalize/normalize.rb Modified files: trunk/lib/unicode_normalize/normalize.rb trunk/lib/unicode_normalize.rb Index: lib/unicode_normalize/normalize.rb =================================================================== --- lib/unicode_normalize/normalize.rb (revision 58536) +++ lib/unicode_normalize/normalize.rb (revision 58537) @@ -159,3 +159,9 @@ module UnicodeNormalize # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L159 end end # module + +class String # :nodoc: + def unicode_normalize(form = :nfc) + UnicodeNormalize.normalize(self, form) + end +end Index: lib/unicode_normalize.rb =================================================================== --- lib/unicode_normalize.rb (revision 58536) +++ lib/unicode_normalize.rb (revision 58537) @@ -31,12 +31,7 @@ class String https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize.rb#L31 # def unicode_normalize(form = :nfc) require 'unicode_normalize/normalize.rb' unless defined? UnicodeNormalize - ## The following line can be uncommented to avoid repeated checking for - ## UnicodeNormalize. However, tests didn't show any noticeable speedup - ## when doing this. This comment also applies to the commented out lines - ## in String#unicode_normalize! and String#unicode_normalized?. - # String.send(:define_method, :unicode_normalize, ->(form = :nfc) { UnicodeNormalize.normalize(self, form) } ) - UnicodeNormalize.normalize(self, form) + unicode_normalize form # no recursion, because redefined in unicode_normalize/normalize.rb end # :call-seq: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/