Skip to content
Browse files

Simplify array fast-path checking

We need to evaluate all the pieces anwyay; this means we get less
control flow in the resulting generated code. (We do trade off doing
some evaluations, but the common case is that all of these are true.)
  • Loading branch information...
jnthn committed Apr 9, 2019
1 parent 2eb93b2 commit 286aa29e2a8411bd869c0fe6b38d8ed8184617b9
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/core/Array.pm6
@@ -524,8 +524,9 @@ my class Array { # declared in BOOTSTRAP
# because this is a very hot path, we copied the code from the int candidate
multi method ASSIGN-POS(Array:D: Int:D $pos, Mu \assignee) is raw {
my \assignee_decont := nqp::decont(assignee);
nqp::isge_i($pos, 0) && nqp::isconcrete(nqp::getattr(self,List,'$!reified')) &&
nqp::bitand_i(nqp::isge_i($pos, 0), nqp::isconcrete(nqp::getattr(self,List,'$!reified'))),
?? self!ASSIGN_POS_FAST_PATH($pos, assignee_decont)
!! self!ASSIGN_POS_SLOW_PATH($pos, assignee_decont)

0 comments on commit 286aa29

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