mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #3185 from kou/string-reduce-needless-array
Reduce needless Array generation in some String methods
This commit is contained in:
@@ -354,7 +354,7 @@ class String
|
||||
|
||||
def chars(&block)
|
||||
if block_given?
|
||||
self.split('').map do |i|
|
||||
self.split('').each do |i|
|
||||
block.call(i)
|
||||
end
|
||||
self
|
||||
@@ -366,7 +366,7 @@ class String
|
||||
def each_char(&block)
|
||||
return to_enum :each_char unless block
|
||||
|
||||
split('').map do |i|
|
||||
split('').each do |i|
|
||||
block.call(i)
|
||||
end
|
||||
self
|
||||
@@ -376,7 +376,7 @@ class String
|
||||
len = self.size
|
||||
|
||||
if block_given?
|
||||
self.split('').map do|x|
|
||||
self.split('').each do|x|
|
||||
block.call(x.ord)
|
||||
end
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user