mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rework definition of String#unicode_normalize
simplify String#unicode_normalize in lib/unicode_normalize.rb by redefining it in lib/unicode_normalize/normalize.rb git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
43ae954f90
commit
42b8713703
2 changed files with 7 additions and 6 deletions
|
@ -31,12 +31,7 @@ class String
|
|||
#
|
||||
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:
|
||||
|
|
|
@ -159,3 +159,9 @@ module UnicodeNormalize # :nodoc:
|
|||
end
|
||||
|
||||
end # module
|
||||
|
||||
class String # :nodoc:
|
||||
def unicode_normalize(form = :nfc)
|
||||
UnicodeNormalize.normalize(self, form)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue