Skip to content

Commit

Permalink
Save some more allocations with IO.lines
Browse files Browse the repository at this point in the history
Reading "/usr/share/dict/words": 3.468 -> 3.344 (3%)
  • Loading branch information
lizmat committed Sep 6, 2014
1 parent c53772d commit ff31e66
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/IO/Handle.pm
@@ -1,6 +1,6 @@
my class IO::Handle does IO::FileTestable {
has $!PIO;
has Int $.ins = 0;
has int $.ins;
has $.chomp = Bool::True;
has $.path;
has Bool $!isDir;
Expand Down Expand Up @@ -86,7 +86,7 @@ my class IO::Handle does IO::FileTestable {
$x.=chomp if $.chomp;
return Str if self.eof && $x eq '';

$!ins++;
$!ins = $!ins + 1;
$x;
}

Expand All @@ -110,13 +110,13 @@ my class IO::Handle does IO::FileTestable {
if $.chomp {
gather until nqp::eoffh($!PIO) {
take nqp::readlinefh($!PIO).chomp;
$!ins++;
$!ins = $!ins + 1;
}
}
else {
gather until nqp::eoffh($!PIO) {
take nqp::p6box_s(nqp::readlinefh($!PIO));
$!ins++;
$!ins = $!ins + 1;
}
}
}
Expand All @@ -131,14 +131,14 @@ my class IO::Handle does IO::FileTestable {
gather while $count-- {
last if nqp::eoffh($!PIO);
take nqp::readlinefh($!PIO).chomp;
$!ins++;
$!ins = $!ins + 1;
}
}
else {
gather while $count-- {
last if nqp::eoffh($!PIO);
take nqp::p6box_s(nqp::readlinefh($!PIO));
$!ins++;
$!ins = $!ins + 1;
}
}
}
Expand Down

0 comments on commit ff31e66

Please sign in to comment.