Skip to content

Commit

Permalink
Make Any (-) Map|Iterable about 2x faster
Browse files Browse the repository at this point in the history
- because the right hand side no longer gets coerced to a Set first
- but instead is handled on-the-fly
- possibly without any iteration if the left is equivalent to an empty Set
  • Loading branch information
lizmat committed Jun 25, 2017
1 parent 9936a3b commit e4f3358
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/set_operators.pm
Expand Up @@ -457,6 +457,9 @@ multi sub infix:<(-)>(Mixy:D $a, QuantHash:D $b) {
multi sub infix:<(-)>(QuantHash:D $a, Mixy:D $b) {
Rakudo::QuantHash.DIFFERENCE-MIXY-QUANTHASH($a.Mix, $b)
}
multi sub infix:<(-)>(Mixy:D $a, Map:D $b) {
Rakudo::QuantHash.DIFFERENCE-MIXY-QUANTHASH($a, $b.Set)
}
multi sub infix:<(-)>(Mixy:D $a, Any:D $b) { # also Iterable
Rakudo::QuantHash.DIFFERENCE-MIXY-QUANTHASH($a, $b.Set)
}
Expand All @@ -475,12 +478,18 @@ multi sub infix:<(-)>(Baggy:D $a, QuantHash:D $b) {
multi sub infix:<(-)>(QuantHash:D $a, Baggy:D $b) {
Rakudo::QuantHash.DIFFERENCE-BAGGY-QUANTHASH($a.Bag, $b)
}
multi sub infix:<(-)>(Baggy:D $a, Map:D $b) {
Rakudo::QuantHash.DIFFERENCE-BAGGY-QUANTHASH($a, $b.Set)
}
multi sub infix:<(-)>(Baggy:D $a, Any:D $b) { # also Iterable
Rakudo::QuantHash.DIFFERENCE-BAGGY-QUANTHASH($a, $b.Set)
}
multi sub infix:<(-)>(Any:D $a, Baggy:D $b) {
Rakudo::QuantHash.DIFFERENCE-BAGGY-QUANTHASH($a.Bag, $b)
}
multi sub infix:<(-)>(Any:D $a, Map:D $b) { infix:<(-)>($a.Set, $b) }
multi sub infix:<(-)>(Any:D $a, Iterable:D $b) { infix:<(-)>($a.Set, $b) }
multi sub infix:<(-)>(Any:D $a, Any:D $b) { infix:<(-)>($a.Set, $b.Set) }

multi sub infix:<(-)>(**@p) {
return set() unless @p;
Expand Down

0 comments on commit e4f3358

Please sign in to comment.