mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Improvements to String#each_byte
Each byte value is now retrieved inside the loop.
This commit is contained in:
+2
-3
@@ -150,10 +150,9 @@ class String
|
||||
# Call the given block for each byte of +self+.
|
||||
def each_byte(&block)
|
||||
return to_enum(:each_byte, &block) unless block
|
||||
bytes = self.bytes
|
||||
pos = 0
|
||||
while pos < bytes.size
|
||||
block.call(bytes[pos])
|
||||
while pos < bytesize
|
||||
block.call(getbyte(pos))
|
||||
pos += 1
|
||||
end
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user