提交 62a02289 编写于 作者: M Manfred Stienstra

Improve performance of Multibyte::Utils.

Replace explicit for-loops by faster enumeration methods.

[#3158 state:committed]
上级 935bd0fe
......@@ -26,11 +26,11 @@ def self.verify(string)
else
def self.verify(string)
if expression = valid_character
for c in string.split(//)
return false unless expression.match(c)
end
# Splits the string on character boundaries, which are determined based on $KCODE.
string.split(//).all? { |c| expression.match(c) }
else
true
end
true
end
end
......@@ -49,9 +49,8 @@ def self.clean(string)
else
def self.clean(string)
if expression = valid_character
stripped = []; for c in string.split(//)
stripped << c if expression.match(c)
end; stripped.join
# Splits the string on character boundaries, which are determined based on $KCODE.
string.split(//).grep(expression).join
else
string
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册