[前][次][番号順一覧][スレッド一覧]

ruby-changes:71159

From: Nobuyoshi <ko1@a...>
Date: Sat, 12 Feb 2022 15:23:04 +0900 (JST)
Subject: [ruby-changes:71159] e95ad70079 (master): [ruby/rdoc] Update generated files

https://git.ruby-lang.org/ruby.git/commit/?id=e95ad70079

From e95ad700799b996cf298c3de956f8075253ca57f Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 12 Feb 2022 15:22:47 +0900
Subject: [ruby/rdoc] Update generated files

---
 lib/rdoc/markdown/literals.rb | 32 ++++++++++++++++++++++++--------
 lib/rdoc/rd/block_parser.rb   |  2 +-
 lib/rdoc/rd/inline_parser.rb  |  2 +-
 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 https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markdown/literals.rb#L29
       @result = nil
       @failed_rule = nil
       @failing_rule_offset = -1
+      @line_offsets = nil
 
       setup_foreign_grammar
     end
@@ -45,17 +46,32 @@ class RDoc::Markdown::Literals https://github.com/ruby/ruby/blob/trunk/lib/rdoc/markdown/literals.rb#L46
       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 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/rd/block_parser.rb#L1
 # 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 @@ https://github.com/ruby/ruby/blob/trunk/lib/rdoc/rd/inline_parser.rb#L1
 # 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 "".
 #
 
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]