[macruby-changes] [2387] MacRuby/trunk/lib

source_changes at macosforge.org source_changes at macosforge.org
Tue Aug 25 20:12:08 PDT 2009


Revision: 2387
          http://trac.macosforge.org/projects/ruby/changeset/2387
Author:   lsansonetti at apple.com
Date:     2009-08-25 20:12:07 -0700 (Tue, 25 Aug 2009)
Log Message:
-----------
hacked a few things for performance purpose

Modified Paths:
--------------
    MacRuby/trunk/lib/mathn.rb
    MacRuby/trunk/lib/prime.rb

Modified: MacRuby/trunk/lib/mathn.rb
===================================================================
--- MacRuby/trunk/lib/mathn.rb	2009-08-26 03:11:19 UTC (rev 2386)
+++ MacRuby/trunk/lib/mathn.rb	2009-08-26 03:12:07 UTC (rev 2387)
@@ -13,8 +13,8 @@
 require "matrix.rb"
 require "prime.rb"
 
-require "mathn/rational"
-require "mathn/complex"
+#require "mathn/rational"
+#require "mathn/complex"
 
 unless defined?(Math.exp!)
   Object.instance_eval{remove_const :Math}

Modified: MacRuby/trunk/lib/prime.rb
===================================================================
--- MacRuby/trunk/lib/prime.rb	2009-08-26 03:11:19 UTC (rev 2386)
+++ MacRuby/trunk/lib/prime.rb	2009-08-26 03:12:07 UTC (rev 2387)
@@ -146,8 +146,8 @@
   def prime?(value, generator = Prime::Generator23.new)
     for num in generator
       q,r = value.divmod num
-      return true if q < num
-      return false if r == 0
+      break true if q < num
+      break false if r == 0
     end
   end
 
@@ -334,7 +334,7 @@
 	  when 3; @prime = 5; @step = 2
 	  end
 	end
-	return @prime
+	break @prime
       end
     end
     alias next succ
@@ -408,11 +408,13 @@
     def next_to(n)
       n = (n-1).div(2)*2+3 # the next odd number of given n
       i,j = n.divmod(32)
-      loop do
+      while true do
 	extend_table until @table.length > i
 	if !@table[i].zero?
-	  (j...32).step(2) do |k|
+          k = j;
+          while k <= 32
 	    return 32*i+k if !@table[i][k.div(2)].zero?
+            k += 2
 	  end
 	end
 	i += 1; j = 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090825/f5ba8fad/attachment.html>


More information about the macruby-changes mailing list