Skip to content

Commit

Permalink
Make hash slices without adverbs about 5x as fast
Browse files Browse the repository at this point in the history
By using the new R:I.AssociativeIterableKeys iterator.
  • Loading branch information
lizmat committed Nov 15, 2018
1 parent 6fe2789 commit b83179f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/hash_slice.pm6
Expand Up @@ -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;
Expand Down

0 comments on commit b83179f

Please sign in to comment.