Skip to content

Commit

Permalink
Work with bytes directly which is more efficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
vitobotta committed Apr 12, 2024
1 parent 56d6da7 commit bf79334
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/util/prefixed_io.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ class PrefixedIO < IO
end

def write(slice : Bytes) : Nil
content = String.new(slice)
content.lines.each do |line|
@io << @prefix << "#{line}\n"
@io.print @prefix
slice.each do |byte|
@io.write_byte byte
@io.print @prefix if 10 == byte
end
end
end

0 comments on commit bf79334

Please sign in to comment.