Created
September 29, 2015 07:57
-
-
Save lizmat/d38a48beded67ab971ff to your computer and use it in GitHub Desktop.
diff causing a infinite loop in the optimizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/IO/Handle.pm b/src/core/IO/Handle.pm | |
index 1baf95b..215b3ef 100644 | |
--- a/src/core/IO/Handle.pm | |
+++ b/src/core/IO/Handle.pm | |
@@ -154,6 +154,17 @@ my class IO::Handle does IO { | |
$c; | |
} | |
+ method !readcharsfh(int $chars) { | |
+#?if jvm | |
+ my Buf $buf := Buf.new; # nqp::readcharsfh doesn't work on the JVM | |
+ nqp::readfh($!PIO, $buf, $chars); # optimize for ASCII | |
+ nqp::unbox_s($buf.decode); | |
+#?endif | |
+#?if !jvm | |
+ nqp::readcharsfh($!PIO, $chars); # optimize for ASCII | |
+#?endif | |
+ } | |
+ | |
proto method words (|) { * } | |
multi method words(IO::Handle:D: :$close) { | |
X::NYI.new(feature => "'words' without closing the file handle").throw | |
@@ -167,7 +178,7 @@ my class IO::Handle does IO { | |
submethod BUILD(\handle, $!close) { | |
$!handle := handle; | |
- $!str = self!readcharsfh(); | |
+ $!str = $!handle!readcharsfh(65536); | |
$!pos = nqp::findnotcclass( | |
nqp::const::CCLASS_WHITESPACE, $!str, 0, nqp::chars($!str)); | |
self | |
@@ -175,21 +186,11 @@ my class IO::Handle does IO { | |
method new(\handle, \close) { | |
nqp::create(self).BUILD(handle, close); | |
} | |
- method !readcharsfh() { | |
- my Mu $PIO := nqp::getattr($!handle, IO::Handle, '$!PIO'); | |
-#?if jvm | |
- my Buf $buf := Buf.new; # nqp::readcharsfh doesn't work on the JVM | |
- nqp::readfh($PIO, $buf, 65536); # optimize for ASCII | |
- nqp::unbox_s($buf.decode); | |
-#?endif | |
-#?if !jvm | |
- nqp::readcharsfh($PIO, 65536); # optimize for ASCII | |
-#?endif | |
- } | |
method !next-chunk(\chars) { | |
$!str = $!pos < chars | |
- ?? nqp::concat(nqp::substr($!str,$!pos),self!readcharsfh) | |
- !! self!readcharsfh; | |
+ ?? nqp::concat( | |
+ nqp::substr($!str,$!pos),$!handle!readcharsfh(65536)) | |
+ !! $!handle!readcharsfh(65536); | |
chars = nqp::chars($!str); | |
$!pos = chars | |
?? nqp::findnotcclass( | |
@@ -479,10 +480,10 @@ my class IO::Handle does IO { | |
else { | |
supply { | |
my int $chars = $size; | |
- my str $str = nqp::readcharsfh($!PIO,$chars); | |
+ my str $str = self!readcharsfh($chars); | |
while nqp::chars($str) { | |
emit nqp::p6box_s($str); | |
- $str = nqp::readcharsfh($!PIO,$chars); | |
+ $str = self!readcharsfh($chars); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment