From d43e3321b512008f7077cdc14e84cca82020fdec Mon Sep 17 00:00:00 2001 From: keiju Date: Tue, 25 Dec 2012 16:04:52 +0000 Subject: * 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 --- lib/irb/ruby-lex.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/irb') 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 -- cgit v1.2.3