diff options
author | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-05-16 22:35:18 +0900 |
---|---|---|
committer | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-05-24 20:10:14 +0900 |
commit | b9950c22b38456537af92c77210f1b837bdc914c (patch) | |
tree | 18f9e59af518c6f4bec3575bb8c56f3340aed155 /lib | |
parent | 14c0833c1c9f1633ab6d3e791decd57eb7422c4f (diff) | |
download | gitlab-ce-b9950c22b38456537af92c77210f1b837bdc914c.tar.gz |
Use each_line. Avoid comparison of partial. Add UTF-8 spec.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/trace/stream.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb index 546f6788a78..56d6855c3c6 100644 --- a/lib/gitlab/ci/trace/stream.rb +++ b/lib/gitlab/ci/trace/stream.rb @@ -125,11 +125,10 @@ module Gitlab stream.seek(-pos, IO::SEEK_END) stream.read(BUFFER_SIZE).tap do |buf| buf = buf + debris - lines = buf.split("\n") - lines.reverse.each do |line| + debris, *lines = buf.each_line.to_a + lines.reverse_each do |line| yield(line) end - debris = lines.count > 0 ? lines[0] : '' end pos += BUFFER_SIZE end @@ -139,8 +138,7 @@ module Gitlab last = (max > BUFFER_SIZE) ? (max % BUFFER_SIZE) : max stream.read(last).tap do |buf| buf = buf + debris - lines = buf.split("\n") - lines.reverse.each do |line| + buf.each_line.reverse_each do |line| yield(line) end end |