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

ruby-changes:22111

From: marcandre <ko1@a...>
Date: Fri, 30 Dec 2011 15:04:19 +0900 (JST)
Subject: [ruby-changes:22111] marcandRe: r34160 (trunk): * lib/matrix.rb (symmetric?): Trivial optimization

marcandre	2011-12-30 15:04:04 +0900 (Fri, 30 Dec 2011)

  New Revision: 34160

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

  Log:
    * lib/matrix.rb (symmetric?): Trivial optimization

  Modified files:
    trunk/lib/matrix.rb

Index: lib/matrix.rb
===================================================================
--- lib/matrix.rb	(revision 34159)
+++ lib/matrix.rb	(revision 34160)
@@ -718,9 +718,10 @@
   #
   def symmetric?
     Matrix.Raise ErrDimensionMismatch unless square?
-    each_with_index(:strict_upper).all? do |e, row, col|
-      e == rows[col][row]
+    each_with_index(:strict_upper) do |e, row, col|
+      return false if e != rows[col][row]
     end
+    true
   end
 
   #

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

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