Skip to content

Instantly share code, notes, and snippets.

Created September 5, 2010 17:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/566173 to your computer and use it in GitHub Desktop.
diff --git a/src/core/IO.pm b/src/core/IO.pm
index e011b01..5a364bd 100644
--- a/src/core/IO.pm
+++ b/src/core/IO.pm
@@ -214,10 +214,13 @@ sub close($handle) {
}
sub slurp($filename) {
- my $handle = open($filename, :r);
- my $contents = $handle.slurp();
- $handle.close();
- $contents
+ ## Although it's tempting to delegate to IO.slurp above, Parrot
+ ## currently suffers a serious (25x) performance degradation when
+ ## using readall() on an already-opened FileHandle. Much faster
+ ## is to use readall($filename), which we do here. See TT #1749.
+ my $PIO = Q:PIR { %r = root_new['parrot';'FileHandle'] };
+ $PIO.encoding('utf8');
+ $PIO.readall($filename);
}
sub unlink($filename) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment