Browse files

Optimize Buf.eqv a bit.

  • Loading branch information...
1 parent 9ec36bd commit 35818f885be581e339cc2bf382bd66dda6f57dd1 @jnthn jnthn committed Jul 26, 2013
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/core/Buf.pm
View
16 src/core/Buf.pm
@@ -321,8 +321,20 @@ multi sub infix:<~^>(Blob:D $a, Blob:D $b) {
}
multi infix:<eqv>(Blob:D $a, Blob:D $b) {
- $a.WHAT === $b.WHAT && $a.elems == $b.elems &&
- [&&] $a.list Z== $b.list
+ if $a.WHAT === $b.WHAT && $a.elems == $b.elems {
+ my int $n = $a.elems;
+ my int $i = 0;
+ my Mu $da := nqp::decont($a);
+ my Mu $db := nqp::decont($b);
+ while $i < $n {
+ return False unless nqp::iseq_i(nqp::atpos_i($da, $i), nqp::atpos_i($db, $i));
+ $i = $i + 1;
+ }
+ True
+ }
+ else {
+ False
+ }
}
multi sub infix:<cmp>(Blob:D $a, Blob:D $b) {

0 comments on commit 35818f8

Please sign in to comment.