Skip to content

Commit

Permalink
use StringScanner.concat
Browse files Browse the repository at this point in the history
  • Loading branch information
levinalex committed Jun 12, 2011
1 parent 3dfdb77 commit 7f3288a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/packet_io/io_listener.rb
Expand Up @@ -84,12 +84,11 @@ class LineBasedProtocol < Base
# @param [String] data
#
def receive(data)
@memo ||= ""
scanner = StringScanner.new(@memo + data)
while s = scanner.scan(/.*?\n/)
@data ||= StringScanner.new("")
@data = @data.concat(data)
while s = @data.scan(/.*?\n/)
forward(s.strip)
end
@memo = scanner.rest
nil
end

Expand Down

0 comments on commit 7f3288a

Please sign in to comment.