Open p5pRT opened 5 years ago
Had written my own stat module and timed it against File::stat in core.
stdstat.pl s/iter Core New Core 10.6 -- -30% New 7.43 43% --
My new version seems about 40% faster than the one in core so it seems it would be good to fix that...
patch against 5.26.2:
diff -wu stat.pm stat2.pm
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 - -While this class is currently implemented using the Class::Struct -module to build a struct-like class\, you shouldn't rely upon this. - =head1 AUTHOR
Tom Christians +Linda Walsh
Migrated from rt.perl.org#134096 (status was 'new')
Searchable as RT134096$