diff options
author | duerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-02 05:15:04 +0000 |
---|---|---|
committer | duerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-02 05:15:04 +0000 |
commit | 42b8713703606011cff7dd4ed488fe9adbcebb2a (patch) | |
tree | c1e73b6d379dc4036538fc13a437e4e336c2f700 | |
parent | 43ae954f90bd676fc22e485c05cb2d37dc29812d (diff) | |
download | ruby-42b8713703606011cff7dd4ed488fe9adbcebb2a.tar.gz |
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
-rw-r--r-- | lib/unicode_normalize.rb | 7 | ||||
-rw-r--r-- | lib/unicode_normalize/normalize.rb | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/unicode_normalize.rb b/lib/unicode_normalize.rb index e71f1e8139..cf99a13572 100644 --- a/lib/unicode_normalize.rb +++ b/lib/unicode_normalize.rb @@ -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: diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb index e87327a9fe..759197d02c 100644 --- a/lib/unicode_normalize/normalize.rb +++ b/lib/unicode_normalize/normalize.rb @@ -159,3 +159,9 @@ module UnicodeNormalize # :nodoc: end end # module + +class String # :nodoc: + def unicode_normalize(form = :nfc) + UnicodeNormalize.normalize(self, form) + end +end |