summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2021-05-16 23:46:30 -0600
committerDan Allen <dan.j.allen@gmail.com>2021-05-17 00:16:42 -0600
commit4efbeeb9ad6bbc13acd1dce9b7db4dcd163badbd (patch)
tree43ba249ec19c29e6023e36284bce02852b151779 /lib
parent2682c1337d5c5a66bc6baeade769afe2da4db0fa (diff)
format code in Document#resolve_id to make it easier to read
Diffstat (limited to 'lib')
-rw-r--r--lib/asciidoctor/document.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb
index b6c014a3..1417dcf8 100644
--- a/lib/asciidoctor/document.rb
+++ b/lib/asciidoctor/document.rb
@@ -619,10 +619,17 @@ class Document < AbstractBlock
# @reftexts is set eagerly to prevent nested lazy init
(@reftexts = {}).tap {|accum| @catalog[:refs].each {|id, ref| accum[ref.xreftext] ||= id } }[text]
else
- # @reftexts is set eagerly to prevent nested lazy init
resolved_id = nil
- # NOTE short-circuit early since we're throwing away this table
- (@reftexts = {}).tap {|accum| @catalog[:refs].each {|id, ref| (xreftext = ref.xreftext) == text ? (break (resolved_id = id)) : (accum[xreftext] ||= id) } }
+ # @reftexts is set eagerly to prevent nested lazy init
+ @reftexts = accum = {}
+ @catalog[:refs].each do |id, ref|
+ # NOTE short-circuit early since we're throwing away this table anyway
+ if (xreftext = ref.xreftext) == text
+ resolved_id = id
+ break
+ end
+ accum[xreftext] ||= id
+ end
@reftexts = nil
resolved_id
end