summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-02-12 15:22:47 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-02-12 15:22:47 +0900
commite95ad700799b996cf298c3de956f8075253ca57f (patch)
treebf5bf969189ca22ab3a3728e7eb310a9e0a947a1 /lib
parent5348a34504a67597e3a3ed98a3020dfd762241ad (diff)
[ruby/rdoc] Update generated files
Diffstat (limited to 'lib')
-rw-r--r--lib/rdoc/markdown/literals.rb32
-rw-r--r--lib/rdoc/rd/block_parser.rb2
-rw-r--r--lib/rdoc/rd/inline_parser.rb2
3 files changed, 26 insertions, 10 deletions
diff --git a/lib/rdoc/markdown/literals.rb b/lib/rdoc/markdown/literals.rb
index 943c2d268a..4c36672de7 100644
--- a/lib/rdoc/markdown/literals.rb
+++ b/lib/rdoc/markdown/literals.rb
@@ -29,6 +29,7 @@ class RDoc::Markdown::Literals
@result = nil
@failed_rule = nil
@failing_rule_offset = -1
+ @line_offsets = nil
setup_foreign_grammar
end
@@ -45,17 +46,32 @@ class RDoc::Markdown::Literals
target + 1
end
- def current_line(target=pos)
- cur_offset = 0
- cur_line = 0
+ if [].respond_to? :bsearch_index
+ def current_line(target=pos)
+ unless @line_offsets
+ @line_offsets = []
+ total = 0
+ string.each_line do |line|
+ total += line.size
+ @line_offsets << total
+ end
+ end
- string.each_line do |line|
- cur_line += 1
- cur_offset += line.size
- return cur_line if cur_offset >= target
+ @line_offsets.bsearch_index {|x| x >= target } + 1 || -1
end
+ else
+ def current_line(target=pos)
+ cur_offset = 0
+ cur_line = 0
+
+ string.each_line do |line|
+ cur_line += 1
+ cur_offset += line.size
+ return cur_line if cur_offset >= target
+ end
- -1
+ -1
+ end
end
def lines
diff --git a/lib/rdoc/rd/block_parser.rb b/lib/rdoc/rd/block_parser.rb
index 462ba869a2..eb7d46925b 100644
--- a/lib/rdoc/rd/block_parser.rb
+++ b/lib/rdoc/rd/block_parser.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
#
# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.5.2
+# This file is automatically generated by Racc 1.6.0
# from Racc grammar file "".
#
diff --git a/lib/rdoc/rd/inline_parser.rb b/lib/rdoc/rd/inline_parser.rb
index 8f4c2c31ef..c1da35a109 100644
--- a/lib/rdoc/rd/inline_parser.rb
+++ b/lib/rdoc/rd/inline_parser.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
#
# DO NOT MODIFY!!!!
-# This file is automatically generated by Racc 1.5.2
+# This file is automatically generated by Racc 1.6.0
# from Racc grammar file "".
#