Skip to content

Commit

Permalink
Use lexical for pull-one results
Browse files Browse the repository at this point in the history
It appears that using $_ for that results in poorer optimizations.
Suspecting that $_ cannot be lowered or something like that.
  • Loading branch information
lizmat committed Oct 17, 2020
1 parent ff2f2b0 commit 420cb1f
Showing 1 changed file with 72 additions and 35 deletions.
107 changes: 72 additions & 35 deletions src/core.e/hash_multislice.pm6
Expand Up @@ -28,8 +28,11 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
$return-list = 1;
my $iterator := idx.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
EXISTS-KEY-recursively(SELF, $_)
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
EXISTS-KEY-recursively(SELF, pulled)
);
}
elsif $dim < $dims {
Expand All @@ -39,8 +42,11 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
my \next-idx := nqp::atpos($indices,$dim);
my $iterator := SELF.keys.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
EXISTS-KEY-recursively(SELF.AT-KEY($_), next-idx)
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
EXISTS-KEY-recursively(SELF.AT-KEY(pulled), next-idx)
);
}
else {
Expand All @@ -53,17 +59,24 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
elsif nqp::istype(idx,Whatever) {
$return-list = 1;
my $iterator := SELF.keys.iterator;
nqp::if(
$exists,
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
nqp::push(target,SELF.EXISTS-KEY($_))
),
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
nqp::push(target,!SELF.EXISTS-KEY($_))
)
);
if $exists {
nqp::until(
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
nqp::push(target,SELF.EXISTS-KEY(pulled))
);
}
else {
nqp::until(
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
nqp::push(target,!SELF.EXISTS-KEY(pulled))
);
}
}
elsif $exists {
nqp::push(target,SELF.EXISTS-KEY(idx));
Expand All @@ -82,8 +95,11 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
$return-list = 1;
my $iterator := idx.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
DELETE-KEY-recursively(SELF, $_)
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
DELETE-KEY-recursively(SELF, pulled)
);
}
elsif $dim < $dims {
Expand All @@ -93,8 +109,11 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
my \next-idx := nqp::atpos($indices,$dim);
my $iterator := SELF.keys.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
DELETE-KEY-recursively(SELF.AT-KEY($_), next-idx)
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
DELETE-KEY-recursively(SELF.AT-KEY(pulled), next-idx)
);
}
else {
Expand All @@ -108,8 +127,11 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
$return-list = 1;
my $iterator := SELF.keys.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
nqp::push(target,SELF.DELETE-KEY($_))
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
nqp::push(target,SELF.DELETE-KEY(pulled))
);
}
else {
Expand Down Expand Up @@ -245,21 +267,30 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
$return-list = 1;
my $iterator := idx.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
PROCESS-KEY-recursively(SELF, $_)
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
PROCESS-KEY-recursively(SELF, pulled)
);
}
elsif $dim < $dims {
++$dim; # going deeper
if nqp::istype(idx,Whatever) {
$return-list = 1;
my $iterator := SELF.keys.iterator;
my \next-idx := nqp::atpos($indices,$dim);
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
nqp::stmts(
(my \next-idx := nqp::atpos($indices,$dim)),
nqp::push($keys,$_),
PROCESS-KEY-recursively(SELF.AT-KEY($_), next-idx),
nqp::push($keys,pulled),
PROCESS-KEY-recursively(
SELF.AT-KEY(pulled),
next-idx
),
nqp::pop($keys)
)
);
Expand All @@ -277,8 +308,11 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
$return-list = 1;
my $iterator := SELF.keys.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
process(SELF, $_)
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
process(SELF, pulled)
);
}
else {
Expand All @@ -299,8 +333,8 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
$return-list = 1;
my $iterator := idx.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
AT-KEY-recursively(SELF, $_)
nqp::eqaddr((my \pulled := $iterator.pull-one),IterationEnd),
AT-KEY-recursively(SELF, pulled)
);
}
elsif $dim < $dims {
Expand All @@ -310,8 +344,11 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
my \next-idx := nqp::atpos($indices,$dim);
my $iterator := SELF.keys.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
AT-KEY-recursively(SELF.AT-KEY($_), next-idx)
nqp::eqaddr(
(my \pulled := $iterator.pull-one),
IterationEnd
),
AT-KEY-recursively(SELF.AT-KEY(pulled), next-idx)
);
}
else {
Expand All @@ -325,8 +362,8 @@ multi sub postcircumfix:<{; }>(\initial-SELF, @indices,
$return-list = $non-deterministic = 1;
my $iterator := SELF.keys.iterator;
nqp::until(
nqp::eqaddr(($_ := $iterator.pull-one),IterationEnd),
nqp::push(target,SELF.AT-KEY($_))
nqp::eqaddr((my \pulled := $iterator.pull-one),IterationEnd),
nqp::push(target,SELF.AT-KEY(pulled))
);
}
else {
Expand Down

0 comments on commit 420cb1f

Please sign in to comment.