diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2019-02-18 23:58:19 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2019-02-19 00:02:30 -0700 |
| commit | aa2216063413ffb75e0d130cff72f2bad69e1448 (patch) | |
| tree | 157647657a3d76b80286e6e4b00d2c0aa99a0a64 | |
| parent | 569e9e229b33de708038348dc94869da342dbaa8 (diff) | |
use map for cache of delimited block line heads
| -rw-r--r-- | lib/asciidoctor.rb | 2 | ||||
| -rw-r--r-- | lib/asciidoctor/parser.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/asciidoctor.rb b/lib/asciidoctor.rb index 185fcd29..f10124f0 100644 --- a/lib/asciidoctor.rb +++ b/lib/asciidoctor.rb @@ -285,7 +285,7 @@ module Asciidoctor '```' => [:fenced_code, ::Set.new] } - DELIMITED_BLOCK_HEADS = ::Set.new.tap {|accum| DELIMITED_BLOCKS.each_key {|k| accum << (k.slice 0, 2) } } + DELIMITED_BLOCK_HEADS = {}.tap {|accum| DELIMITED_BLOCKS.each_key {|k| accum[k.slice 0, 2] = k } } DELIMITED_BLOCK_TAILS = {}.tap {|accum| DELIMITED_BLOCKS.each_key {|k| accum[k] = k.slice k.length - 1 if k.length == 4 } } LAYOUT_BREAK_CHARS = { diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb index ced6809a..5ccb3fc8 100644 --- a/lib/asciidoctor/parser.rb +++ b/lib/asciidoctor/parser.rb @@ -919,7 +919,7 @@ class Parser # returns the match data if this line is the first line of a delimited block or nil if not def self.is_delimited_block? line, return_match_data = false # highly optimized for best performance - return unless (line_len = line.length) > 1 && DELIMITED_BLOCK_HEADS.include?(line.slice 0, 2) + return unless (line_len = line.length) > 1 && DELIMITED_BLOCK_HEADS[line.slice 0, 2] # catches open block if line_len == 2 tip = line |
