summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2023-05-13 01:01:27 -0600
committerDan Allen <dan.j.allen@gmail.com>2023-05-13 01:02:12 -0600
commit3ae665c111d9497545d60b34fd7c01032e12cbee (patch)
tree2754a5fe8e52f981d51469f444cbf0f30b52aee3
parent854d0206db527cef8e89107bfa7b2702ce0c8566 (diff)
slightly optimize code when querying for extensions
-rw-r--r--lib/asciidoctor/extensions.rb10
-rw-r--r--lib/asciidoctor/reader.rb4
2 files changed, 5 insertions, 9 deletions
diff --git a/lib/asciidoctor/extensions.rb b/lib/asciidoctor/extensions.rb
index 8b2f0deb..579f1a91 100644
--- a/lib/asciidoctor/extensions.rb
+++ b/lib/asciidoctor/extensions.rb
@@ -1120,11 +1120,7 @@ module Extensions
# Returns the [Extension] proxy object for the BlockProcessor that matches
# the block name and context or false if no match is found.
def registered_for_block? name, context
- if (ext = @block_extensions[name.to_sym])
- (ext.config[:contexts].include? context) ? ext : false
- else
- false
- end
+ (ext = @block_extensions[name.to_sym]) ? (ext.config[:contexts].include? context) && ext : false
end
# Public: Retrieves the {Extension} proxy object for the BlockProcessor registered
@@ -1219,7 +1215,7 @@ module Extensions
#--
# TODO only allow blank target if format is :short
def registered_for_block_macro? name
- (ext = @block_macro_extensions[name.to_sym]) ? ext : false
+ @block_macro_extensions[name.to_sym] || false
end
# Public: Retrieves the {Extension} proxy object for the BlockMacroProcessor registered
@@ -1312,7 +1308,7 @@ module Extensions
# Returns the [Extension] proxy object for the InlineMacroProcessor that matches
# the macro name or false if no match is found.
def registered_for_inline_macro? name
- (ext = @inline_macro_extensions[name.to_sym]) ? ext : false
+ @inline_macro_extensions[name.to_sym] || false
end
# Public: Retrieves the {Extension} proxy object for the InlineMacroProcessor registered
diff --git a/lib/asciidoctor/reader.rb b/lib/asciidoctor/reader.rb
index fbbad007..798925ce 100644
--- a/lib/asciidoctor/reader.rb
+++ b/lib/asciidoctor/reader.rb
@@ -758,8 +758,8 @@ class PreprocessorReader < Reader
def include_processors?
if @include_processor_extensions.nil?
- if @document.extensions? && @document.extensions.include_processors?
- (@include_processor_extensions = @document.extensions.include_processors) ? true : false
+ if @document.extensions? && (@include_processor_extensions = @document.extensions.include_processors)
+ true
else
@include_processor_extensions = false
end