Skip to content
Permalink
Browse files

Remove EmptySeq, in response to R#2281

This actually, surprisingly, reduces the .moarvm file by 2.5K
  • Loading branch information...
lizmat committed Sep 16, 2018
1 parent b1a07f0 commit a4db33e72b140cf6e48cde955e3766169baad8b1
Showing with 10 additions and 16 deletions.
  1. +2 −2 src/core/IO/CatHandle.pm6
  2. +1 −1 src/core/IO/Spec/Unix.pm6
  3. +2 −2 src/core/List.pm6
  4. +1 −1 src/core/Mixy.pm6
  5. +4 −4 src/core/Range.pm6
  6. +0 −6 src/core/Seq.pm6
@@ -138,7 +138,7 @@ my class IO::CatHandle is IO::Handle {
nqp::while(
nqp::defined(self.next-handle),
take $!active-handle.words)}),
EmptySeq
Seq.new(Rakudo::Iterator.Empty)
)
}
multi method words(::?CLASS:D \SELF: $limit, :$close) {
@@ -164,7 +164,7 @@ my class IO::CatHandle is IO::Handle {
nqp::while(
nqp::defined(self.next-handle),
take $!active-handle.lines)}),
EmptySeq
Seq.new(Rakudo::Iterator.Empty)
)
}
multi method lines(::?CLASS:D \SELF: $limit, :$close) {
@@ -104,7 +104,7 @@ my class IO::Spec::Unix is IO::Spec {
nqp::until(
nqp::iseq_i($els, $i = nqp::add_i($i, 1)),
take nqp::atpos($parts, $i) || '.')
} !! EmptySeq
} !! Seq.new(Rakudo::Iterator.Empty)
}

method splitpath( $path, :$nofile = False ) {
@@ -1624,7 +1624,7 @@ multi sub infix:<xx>(&x, Whatever) {
Seq.new(Rakudo::Iterator.Callable-xx-Whatever(&x))
}
multi sub infix:<xx>(&x, Bool:D $b) {
$b ?? infix:<xx>(&x, 1) !! EmptySeq
$b ?? infix:<xx>(&x, 1) !! Seq.new(Rakudo::Iterator.Empty)
}
multi sub infix:<xx>(&x, Int:D $n) {
my int $todo = $n;
@@ -1654,7 +1654,7 @@ multi sub infix:<xx>(Mu \x, Whatever) {
Seq.new(Rakudo::Iterator.UnendingValue(x))
}
multi sub infix:<xx>(Mu \x, Bool:D $b) {
$b ?? Seq.new(Rakudo::Iterator.OneValue(x)) !! EmptySeq
Seq.new( $b ?? Rakudo::Iterator.OneValue(x) !! Rakudo::Iterator.Empty )
}
multi sub infix:<xx>(Mu \x, Int:D $n) is pure {
Seq.new(Rakudo::Iterator.OneValueTimes(x,$n))
@@ -39,7 +39,7 @@ my role Mixy does Baggy {
nqp::if(
(my $total := self!total-positive),
self.roll($calculate($total)),
EmptySeq
Seq.new(Rakudo::Iterator.Empty)
)
}
multi method roll(Mixy:D: $count) {
@@ -481,7 +481,7 @@ my class Range is Cool does Iterable does Positional {
?? $!is-int
?? Seq.new(RollWhatever.new($!min + $!excludes-min,elems))
!! self.list.roll(*)
!! EmptySeq
!! Seq.new(Rakudo::Iterator.Empty)
}
multi method roll(Range:D:) {
nqp::if(
@@ -504,7 +504,7 @@ my class Range is Cool does Iterable does Positional {
?? $!is-int
?? Seq.new(RollN.new($!min + $!excludes-min,elems,0 max $todo))
!! self.list.roll($todo)
!! EmptySeq
!! Seq.new(Rakudo::Iterator.Empty)
}

proto method pick(|) {*}
@@ -555,14 +555,14 @@ my class Range is Cool does Iterable does Positional {
multi method pick(Whatever) {
self.elems
?? self.list.pick(*)
!! EmptySeq
!! Seq.new(Rakudo::Iterator.Empty)
}
multi method pick(Int(Cool) $todo) {
(my \elems := self.elems)
?? $!is-int && elems > 3 * $todo # heuristic for sparse lookup
?? Seq.new(PickN.new($!min + $!excludes-min,elems,0 max $todo))
!! self.list.pick($todo)
!! EmptySeq
!! Seq.new(Rakudo::Iterator.Empty)
}

method Capture(Range:D:) {
@@ -214,10 +214,4 @@ multi sub infix:<eqv>(Seq:D \a, Seq:D \b) {
)
}

# The Empty Sequence
my constant EmptySeq = nqp::p6bindattrinvres(
nqp::create( class EmptySeq is Seq {
method iterator() { nqp::getattr(self,Seq,'$!iter') }
}),Seq,'$!iter',Rakudo::Iterator.Empty);

# vim: ft=perl6 expandtab sw=4

0 comments on commit a4db33e

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