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

ruby-changes:26558

From: keiju <ko1@a...>
Date: Wed, 26 Dec 2012 01:05:02 +0900 (JST)
Subject: [ruby-changes:26558] keiju:r38609 (trunk): * lib/irb/ruby-lex.rb: improve RubyLex performance for large files

keiju	2012-12-26 01:04:52 +0900 (Wed, 26 Dec 2012)

  New Revision: 38609

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38609

  Log:
    * lib/irb/ruby-lex.rb: improve RubyLex performance for large files
      [Bug #5202]. Patch by ryanmelt.

  Modified files:
    trunk/ChangeLog
    trunk/lib/irb/ruby-lex.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38608)
+++ ChangeLog	(revision 38609)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec 26 00:59:18 2012  Keiju Ishitsuka  <keiju@i...>
+
+	* 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  <keiju@i...>
 
 	* lib/irb/output-method.rb: raise right exception when
Index: lib/irb/ruby-lex.rb
===================================================================
--- lib/irb/ruby-lex.rb	(revision 38608)
+++ lib/irb/ruby-lex.rb	(revision 38609)
@@ -87,8 +87,8 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L87
   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 https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L152
     @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

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

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