summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-09-18 23:59:14 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-09-19 05:07:13 -0600
commit9cdc77bd1193cbbdc6aeb5b4f758fa8be2024d46 (patch)
tree3e19f5e2b7a0dd86738d16f1aa42fc0f0f6d5502 /lib
parent631b7ab2b302b1533fa690446bf66663f9078d6a (diff)
call merge instead of dup on Hash where possible (more efficient)
Diffstat (limited to 'lib')
-rw-r--r--lib/asciidoctor/pdf/converter.rb6
-rw-r--r--lib/asciidoctor/pdf/ext/prawn/images.rb2
-rw-r--r--lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb6
-rw-r--r--lib/asciidoctor/pdf/formatted_text/source_wrap.rb4
-rw-r--r--lib/asciidoctor/pdf/formatted_text/transform.rb2
5 files changed, 10 insertions, 10 deletions
diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb
index b81d043c..7288b329 100644
--- a/lib/asciidoctor/pdf/converter.rb
+++ b/lib/asciidoctor/pdf/converter.rb
@@ -810,7 +810,7 @@ module Asciidoctor
node.blocks.each do |child|
if child.context == :paragraph
child.document.playback_attributes child.attributes
- convert_paragraph child, prose_opts.dup
+ convert_paragraph child, prose_opts.merge
prose_opts.delete :first_line_options
else
# FIXME: this could do strange things if the wrong kind of content shows up
@@ -1926,7 +1926,7 @@ module Asciidoctor
ink_caption node, labeled: false, end: :bottom if node.title?
theme_margin :block, :bottom, (next_enclosed_block node)
else
- original_attributes = node.attributes.dup
+ original_attributes = node.attributes.merge
begin
node.update_attributes 'target' => poster, 'link' => video_path
convert_image node
@@ -5226,7 +5226,7 @@ module Asciidoctor
if (@scratch_depth += 1) == 1
@save_state = {
catalog: {}.tap {|accum| doc.catalog.each {|k, v| accum[k] = v.dup } },
- attributes: doc.attributes.dup,
+ attributes: doc.attributes.merge,
}
end
end
diff --git a/lib/asciidoctor/pdf/ext/prawn/images.rb b/lib/asciidoctor/pdf/ext/prawn/images.rb
index 414ae4e9..33e084b1 100644
--- a/lib/asciidoctor/pdf/ext/prawn/images.rb
+++ b/lib/asciidoctor/pdf/ext/prawn/images.rb
@@ -7,7 +7,7 @@ module Asciidoctor
def image file, opts = {}
# FIXME: handle case when SVG is an IO object
if ::String === file
- if ((opts = opts.dup).delete :format) == 'svg' || (file.downcase.end_with? '.svg')
+ if ((opts = opts.merge).delete :format) == 'svg' || (file.downcase.end_with? '.svg')
#opts[:enable_file_requests_with_root] = (::File.dirname file) unless opts.key? :enable_file_requests_with_root
#opts[:enable_web_requests] = allow_uri_read if !(opts.key? :enable_web_requests) && (respond_to? :allow_uri_read)
#opts[:cache_images] = cache_uri if !(opts.key? :cache_images) && (respond_to? :cache_uri)
diff --git a/lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb b/lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb
index 24674175..4ded6d49 100644
--- a/lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb
+++ b/lib/asciidoctor/pdf/ext/rouge/formatters/prawn.rb
@@ -51,13 +51,13 @@ module Rouge
linenum = (linenum = opts[:start_line] || 1) > 0 ? linenum : 1
fragments = []
line_numbers ? (fragments << (create_linenum_fragment linenum)) : (start_of_line = true)
- fragments << @highlight_line_fragment.dup if highlight_lines && highlight_lines[linenum]
+ fragments << @highlight_line_fragment.merge if highlight_lines && highlight_lines[linenum]
tokens.each do |tok, val|
if val == LF
fragments << { text: LF }
linenum += 1
line_numbers ? (fragments << (create_linenum_fragment linenum)) : (start_of_line = true)
- fragments << @highlight_line_fragment.dup if highlight_lines && highlight_lines[linenum]
+ fragments << @highlight_line_fragment.merge if highlight_lines && highlight_lines[linenum]
elsif val.include? LF
# NOTE: we assume if the fragment ends in a line feed, the intention was to match a line-oriented form
line_oriented = val.end_with? LF
@@ -72,7 +72,7 @@ module Rouge
# NOTE: eagerly append linenum fragment or line highlight if there's a next line
linenum += 1
line_numbers ? (fragments << (create_linenum_fragment linenum)) : (start_of_line = true)
- fragments << @highlight_line_fragment.dup if highlight_lines && highlight_lines[linenum]
+ fragments << @highlight_line_fragment.merge if highlight_lines && highlight_lines[linenum]
end
else
if start_of_line
diff --git a/lib/asciidoctor/pdf/formatted_text/source_wrap.rb b/lib/asciidoctor/pdf/formatted_text/source_wrap.rb
index f1230ee9..664e63f5 100644
--- a/lib/asciidoctor/pdf/formatted_text/source_wrap.rb
+++ b/lib/asciidoctor/pdf/formatted_text/source_wrap.rb
@@ -18,11 +18,11 @@ module Asciidoctor
if (first_fragment = unconsumed[0])[:linenum]
linenum_text = first_fragment[:text]
linenum_spacer ||= { text: (NoBreakSpace.encode linenum_text.encoding) + (' ' * (linenum_text.length - 1)), linenum: :spacer }
- highlight_line = (second_fragment = unconsumed[1])[:highlight] ? second_fragment.dup : nil
+ highlight_line = (second_fragment = unconsumed[1])[:highlight] ? second_fragment.merge : nil
else # wrapped line
first_fragment[:text] = first_fragment[:text].lstrip
@arranger.unconsumed.unshift highlight_line if highlight_line
- @arranger.unconsumed.unshift linenum_spacer.dup
+ @arranger.unconsumed.unshift linenum_spacer.merge
end
@line_wrap.wrap_line \
document: @document,
diff --git a/lib/asciidoctor/pdf/formatted_text/transform.rb b/lib/asciidoctor/pdf/formatted_text/transform.rb
index 26ba80d0..6e4e8ef7 100644
--- a/lib/asciidoctor/pdf/formatted_text/transform.rb
+++ b/lib/asciidoctor/pdf/formatted_text/transform.rb
@@ -376,7 +376,7 @@ module Asciidoctor
def clone_fragment fragment, append = nil
if fragment
- fragment = fragment.dup
+ fragment = fragment.merge
fragment[:styles] = fragment[:styles].dup if fragment.key? :styles
fragment[:callback] = fragment[:callback].dup if fragment.key? :callback
append ? (fragment.update append) : fragment