Skip to content

Commit

Permalink
Debug: optimized usage of IO#gets using chomp argument
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Feb 12, 2019
1 parent d19e070 commit c295c8a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/debug/dwarf/info.cr
Expand Up @@ -118,7 +118,7 @@ module Debug
when FORM::RefSig8
@io.read_bytes(UInt64)
when FORM::String
@io.gets('\0').to_s.chomp('\0')
@io.gets('\0', chomp: true).to_s
when FORM::Strp
read_ulong
when FORM::Indirect
Expand Down
4 changes: 2 additions & 2 deletions src/debug/dwarf/line_numbers.cr
Expand Up @@ -255,15 +255,15 @@ module Debug

private def read_directory_table(sequence)
loop do
name = @io.gets('\0').to_s.chomp('\0')
name = @io.gets('\0', chomp: true).to_s
break if name.empty?
sequence.include_directories << name
end
end

private def read_filename_table(sequence)
loop do
name = @io.gets('\0').to_s.chomp('\0')
name = @io.gets('\0', chomp: true).to_s
break if name.empty?
dir = DWARF.read_unsigned_leb128(@io)
time = DWARF.read_unsigned_leb128(@io)
Expand Down
2 changes: 1 addition & 1 deletion src/debug/dwarf/strings.cr
Expand Up @@ -6,7 +6,7 @@ module Debug

def decode(strp)
@io.seek(@offset + strp) do
@io.gets('\0').to_s.chomp('\0')
@io.gets('\0', chomp: true).to_s
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/debug/elf.cr
Expand Up @@ -201,7 +201,7 @@ module Debug
def sh_name(index)
sh = section_headers[shstrndx]
@io.seek(sh.offset + index) do
@io.gets('\0').to_s.chomp('\0')
@io.gets('\0', chomp: true).to_s
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/debug/mach_o.cr
Expand Up @@ -458,7 +458,7 @@ module Debug

if nlist.strx > 0
@io.seek(symtab.stroff + nlist.strx) do
nlist.name = @io.gets('\0').to_s.chomp('\0')
nlist.name = @io.gets('\0', chomp: true).to_s
end
end

Expand Down

0 comments on commit c295c8a

Please sign in to comment.