Skip to content

Commit

Permalink
Merge pull request #528 from yob/optimize-hexstring
Browse files Browse the repository at this point in the history
Reduce allocations when parsing hex strings
  • Loading branch information
yob authored Dec 25, 2023
2 parents ea4370c + 803c1b6 commit 7762166
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/pdf/reader/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ def hex_string

# add a missing digit if required, as required by the spec
str << "0" unless str.size % 2 == 0
str.chars.each_slice(2).map { |nibbles|
nibbles.join("").hex.chr
}.join.force_encoding("binary")
[str].pack('H*')
end
################################################################################
# Reads a PDF String from the buffer and converts it to a Ruby String
Expand Down

0 comments on commit 7762166

Please sign in to comment.