Skip to content
Permalink
Browse files

Make hash slices without adverbs about 5x as fast

By using the new R:I.AssociativeIterableKeys iterator.
  • Loading branch information...
lizmat committed Nov 15, 2018
1 parent 6fe2789 commit b83179f0571b23eb3c656319a1d8bddad43c1a6a
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/core/hash_slice.pm6
@@ -49,12 +49,24 @@ multi sub postcircumfix:<{ }>( \SELF, \key, Bool() :$v!, *%other ) is raw {
multi sub postcircumfix:<{ }>( \SELF, Iterable \key ) is raw {
nqp::iscont(key)
?? SELF.AT-KEY(key)
!! key.flatmap({ SELF{$_} }).eager.list;
!! nqp::p6bindattrinvres(nqp::create(List),List,'$!reified',
nqp::stmts(
Rakudo::Iterator.AssociativeIterableKeys(SELF,key)
.push-all(my \buffer := nqp::create(IterationBuffer)),
buffer
)
)
}
multi sub postcircumfix:<{ }>(\SELF, Iterable \key, Mu \ASSIGN) is raw {
nqp::iscont(key)
?? SELF.ASSIGN-KEY(key, ASSIGN)
!! (key.flatmap({ SELF{$_} }).eager.list = ASSIGN)
!! (nqp::p6bindattrinvres(nqp::create(List),List,'$!reified',
nqp::stmts(
Rakudo::Iterator.AssociativeIterableKeys(SELF,key)
.push-all(my \buffer := nqp::create(IterationBuffer)),
buffer
)
) = ASSIGN)
}
multi sub postcircumfix:<{ }>(\SELF, Iterable \key, :$BIND!) is raw {
X::Bind::Slice.new(type => SELF.WHAT).throw;

0 comments on commit b83179f

Please sign in to comment.
You can’t perform that action at this time.