diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-11 21:46:56 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-11 21:46:56 +0900 |
commit | 3c9fd39d9a008c5d78e0c83b243f1d95e709a07a (patch) | |
tree | 317249a9a2fb0cce91a5dc0a2f43e53568145c2c /lib/plum/frame_utils.rb | |
parent | 30b571999a425468d85e354f4958e8d970764f41 (diff) | |
download | plum-3c9fd39d9a008c5d78e0c83b243f1d95e709a07a.tar.gz |
frame_utils: use String#each_byteslice
Diffstat (limited to 'lib/plum/frame_utils.rb')
-rw-r--r-- | lib/plum/frame_utils.rb | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/plum/frame_utils.rb b/lib/plum/frame_utils.rb index 0093f89..d897c22 100644 --- a/lib/plum/frame_utils.rb +++ b/lib/plum/frame_utils.rb @@ -10,10 +10,7 @@ module Plum return [self] if self.length <= max raise "Frame type must be DATA" unless self.type == :data - fragments = [] - while (pos = fragments.size * max) <= self.length # zero - fragments << self.payload.byteslice(pos, max) - end + fragments = self.payload.each_byteslice(max).to_a frames = [] last = Frame.data(stream_id, fragments.pop, *(self.flags & [:end_stream])) @@ -28,10 +25,7 @@ module Plum return [self] if self.length <= max raise "Frame type must be DATA" unless [:headers, :push_promise].include?(self.type) - fragments = [] - while (pos = fragments.size * max) < self.length # zero - fragments << self.payload.byteslice(pos, max) - end + fragments = self.payload.each_byteslice(max).to_a frames = [] frames << Frame.new(type_value: self.type_value, flags: self.flags - [:end_headers], stream_id: self.stream_id, payload: fragments.shift) |