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 --- ChangeLog | 5 +++++ lib/irb/ruby-lex.rb | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89a8200cf2..0980c32ea3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 26 00:59:18 2012 Keiju Ishitsuka + + * lib/irb/ruby-lex.rb: improve RubyLex performance for large files + [Bug #5202]. Patch by ryanmelt. + Tue Dec 25 22:21:06 2012 Keiju Ishitsuka * lib/irb/output-method.rb: raise right exception when 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