summaryrefslogtreecommitdiff
path: root/lib/rdoc/markup
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 23:34:29 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 23:34:29 +0000
commit09af9d7f7ffe1bde891040e0232038130266ccbc (patch)
treedd8ca5acdaa088949c6ddaafa4c80dc7b191bd97 /lib/rdoc/markup
parenta22bb18e3e1f48f1155819351bd40c681f971fe0 (diff)
* lib/rdoc/generator/darkfish.rb: Silenced warning
* test/rdoc/test_rdoc_rdoc.rb: ditto * lib/rdoc/markup/parser.rb: Use byteslice when available for performance * test/rdoc/test_rdoc_markup_parser.rb: Test for above * lib/rdoc/test_case.rb: ditto * lib/rdoc/parser/ruby.rb: Fixed bug parsing yield({}) * test/rdoc/test_rdoc_parser_ruby.rb (end): * lib/rdoc/rubygems_hook.rb: Skip default gems. Display generator name properly. * test/rdoc/test_rdoc_rubygems_hook.rb: Test for above * lib/rdoc/servlet.rb: Fixed typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/markup')
-rw-r--r--lib/rdoc/markup/parser.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/rdoc/markup/parser.rb b/lib/rdoc/markup/parser.rb
index ca384d0639..3fce2b4c3b 100644
--- a/lib/rdoc/markup/parser.rb
+++ b/lib/rdoc/markup/parser.rb
@@ -79,6 +79,8 @@ class RDoc::Markup::Parser
@current_token = nil
@debug = false
@have_encoding = Object.const_defined? :Encoding
+ @have_byteslice = ''.respond_to? :byteslice
+ @input = nil
@input_encoding = nil
@line = 0
@line_pos = 0
@@ -321,7 +323,9 @@ class RDoc::Markup::Parser
# The character offset for the input string at the given +byte_offset+
def char_pos byte_offset
- if @have_encoding then
+ if @have_byteslice then
+ @input.byteslice(0, byte_offset).length
+ elsif @have_encoding then
matched = @binary_input[0, byte_offset]
matched.force_encoding @input_encoding
matched.length
@@ -416,10 +420,11 @@ class RDoc::Markup::Parser
def setup_scanner input
@line = 0
@line_pos = 0
+ @input = input.dup
- if @have_encoding then
- @input_encoding = input.encoding
- @binary_input = input.dup.force_encoding Encoding::BINARY
+ if @have_encoding and not @have_byteslice then
+ @input_encoding = @input.encoding
+ @binary_input = @input.force_encoding Encoding::BINARY
end
@s = StringScanner.new input