diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-30 06:04:04 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-12-30 06:04:04 +0000 |
commit | b906a46edd76e873cec0714eb1e96d68caec363c (patch) | |
tree | 3a9656b7466ec0f9af3474878679a293f5ebe50a | |
parent | f965d513846cdd9775d022f1463d5097e10a9620 (diff) | |
download | ruby-b906a46edd76e873cec0714eb1e96d68caec363c.tar.gz |
* lib/matrix.rb (symmetric?): Trivial optimization
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/matrix.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb index 7a20fae520..7569d68607 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -718,9 +718,10 @@ class Matrix # 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 # |