Skip to content

Commit

Permalink
Further optimizations of push.
Browse files Browse the repository at this point in the history
This cuts the perl6-bench while_push benchmark in half again, and
provides a further small improvement for the push/split benchmark.
  • Loading branch information
jnthn committed Sep 19, 2014
1 parent c0e55a1 commit abc97db
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/List.pm
Expand Up @@ -229,12 +229,12 @@ my class List does Positional { # declared in BOOTSTRAP
}

multi method push(List:D: \value) {
if nqp::iscont(value) || !(nqp::istype(value, Iterable) || nqp::istype(value, Parcel)) {
if nqp::iscont(value) || nqp::not_i(nqp::istype(value, Iterable)) && nqp::not_i(nqp::istype(value, Parcel)) {
$!nextiter.DEFINITE && self.gimme(*);
fail 'Cannot .push to an infinite list' if $!nextiter.DEFINITE;
nqp::p6listitems(self);
nqp::istype(value, self.of)
?? nqp::push($!items, my $ = value)
?? nqp::push($!items, nqp::assign(nqp::p6scalarfromdesc(nqp::null), value))
!! X::TypeCheck.new(
operation => '.push',
expected => self.of,
Expand Down Expand Up @@ -618,7 +618,7 @@ my class List does Positional { # declared in BOOTSTRAP
}

method sink() {
self.gimme(*, :sink) if self.defined;
self.gimme(*, :sink) if self.DEFINITE && $!nextiter.DEFINITE;
Nil;
}

Expand Down

0 comments on commit abc97db

Please sign in to comment.