Skip to content

Commit

Permalink
Make BUILDALL/BUILD_LEAST_DERIVED about 10% faster
Browse files Browse the repository at this point in the history
Benchmarked on a class with 3 public attributes not being initialized
  • Loading branch information
lizmat committed Feb 28, 2016
1 parent 4fbedcc commit bc0070f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/core/Mu.pm
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ Please refactor this code using the new Iterator / Seq interface.
# would get expensive.
my $build_plan := nqp::findmethod(self.HOW, 'BUILDALLPLAN')(self.HOW, self);
my int $count = nqp::elems($build_plan);
my int $i = 0;
while nqp::islt_i($i, $count) {
my int $i = -1;
while nqp::islt_i($i = nqp::add_i($i,1), $count) {
my $task := nqp::atpos($build_plan, $i);
my int $code = nqp::atpos($task, 0);
$i = nqp::add_i($i, 1);
if nqp::iseq_i($code, 0) {
# Custom BUILD call.
nqp::atpos($task, 1)(self, |%attrinit);
Expand Down Expand Up @@ -208,11 +207,10 @@ Please refactor this code using the new Iterator / Seq interface.
# Get the build plan for just this class.
my $build_plan := nqp::findmethod(self.HOW, 'BUILDPLAN')(self.HOW, self);
my int $count = nqp::elems($build_plan);
my int $i = 0;
while nqp::islt_i($i, $count) {
my int $i = -1;
while nqp::islt_i($i = nqp::add_i($i,1), $count) {
my $task := nqp::atpos($build_plan, $i);
my int $code = nqp::atpos($task, 0);
$i = nqp::add_i($i, 1);
if nqp::iseq_i($code, 0) {
# Custom BUILD call.
nqp::atpos($task, 1)(self, |%attrinit);
Expand Down

0 comments on commit bc0070f

Please sign in to comment.