New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix perf deficit in File::Stat (patch against 5.26.2) #16993
Comments
From lawalsh@cpan.orgCreated by lawalsh@cpan.orgHad written my own stat module and timed it against File::stat
My new version seems about 40% faster than the one in core so it patch against 5.26.2:
Inline Patch--- stat.pm 2016-02-05 07:26:06.000000000 -0800
+++ stat.pm 2019-05-11 22:49:23.249216609 -0700
@@ -24,6 +24,22 @@
);
@EXPORT_OK = ( @fields, "stat_cando" );
%EXPORT_TAGS = ( FIELDS => [ @fields, @EXPORT ] );
+ my @field_names = ( qw( dev ino mode nlink uid gid rdev size
+ atime mtime ctime blksize blocks ));
+
+ sub _mk_accessors() {
+ my $offset=-1;
+ for (@field_names) {
+ ++$offset;
+ my $cmd='# line ' . __LINE__ . ' "' . __FILE__ . "\"\n" .
+ 'sub '.$_.'() { $_[0]->['.$offset.'] }';
+ eval "$cmd";
+ die $@ if $@;
+ }
+ }
+
+ &_mk_accessors;
+
}
use vars @fields;
@@ -178,17 +194,8 @@
}
};
-# Class::Struct forbids use of @ISA
sub import { goto &Exporter::import }
-use Class::Struct qw(struct);
-struct 'File::stat' => [
- map { $_ => '$' } qw{
- dev ino mode nlink uid gid rdev size
- atime mtime ctime blksize blocks
- }
-];
-
sub populate (@) {
return unless @_;
my $stob = new();
@@ -346,11 +353,7 @@
=back -=head1 NOTE Tom Christians Perl Info
|
Migrated from rt.perl.org#134096 (status was 'new')
Searchable as RT134096$
The text was updated successfully, but these errors were encountered: