summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-25 16:04:52 +0000
committerkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-25 16:04:52 +0000
commitd43e3321b512008f7077cdc14e84cca82020fdec (patch)
tree4b5c7c3c996cb8af14c1f6a2eeb03d8085929ad7 /lib
parent23c93b500743c784ae9f6b5d766afd1787e752a6 (diff)
* lib/irb/ruby-lex.rb: improve RubyLex performance for large files
[Bug #5202]. Patch by ryanmelt. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/ruby-lex.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 379b4b746d..239d6b1d86 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -87,8 +87,8 @@ class RubyLex
end
def get_readed
- if idx = @readed.reverse.index("\n")
- @base_char_no = idx
+ if idx = @readed.rindex("\n")
+ @base_char_no = @readed.size - (idx + 1)
else
@base_char_no += @readed.size
end
@@ -152,8 +152,8 @@ class RubyLex
@seek -= 1
if c == "\n"
@line_no -= 1
- if idx = @readed.reverse.index("\n")
- @char_no = @readed.size - idx
+ if idx = @readed.rindex("\n")
+ @char_no = idx + 1
else
@char_no = @base_char_no + @readed.size
end