Subject: | IO::InnerFile slurp mode is non-optimal |
Slurp mode on IO::InnerFile filehandles works non-optimally: it slurps
the entire underlying file and then truncates the output. So on a 4G
file with a 100B inner file the whole 4G file gets slurped each time.
Example demonstrating the problem is attached (based on report from
Miles Crawford:
http://groups.google.com/group/brackup/browse_thread/thread/1047aec5cc261a3e).
Suggested patch attached.
Cheers,
Gavin
Subject: | test |
Message body not shown because it is not plain text.
Subject: | io-innerfile-slurp.diff |
--- /usr/share/perl5/IO/InnerFile.pm.dist 2011-11-25 15:08:04.048188626 +1100
+++ /usr/share/perl5/IO/InnerFile.pm 2011-11-25 15:56:18.947465726 +1100
@@ -230,6 +230,12 @@
my ($self) = @_;
return undef if ($self->{CRPOS} >= $self->{LG});
+ # Handle slurp mode
+ if (! defined $/) {
+ $self->READ(my $text, $self->{LG} - $self->{CRPOS});
+ return $text;
+ }
+
### Save and seek...
my $old_pos = $self->{FH}->tell;
$self->{FH}->seek($self->{CRPOS}+$self->{START}, 0);