Subject: | [PATCH] faster contructor |
Hi,
Not for the first time I see people comparing constructors of modules implementing accessors.
It's may be important for systems with a lot of short living objects. So I decided to make it faster
:)
--
Best regards, Ruslan.
Subject: | Class-Accessor-0.34-faster_constructor.patch |
Only in Class-Accessor-0.34-my/: Makefile
Only in Class-Accessor-0.34-my/: blib
diff -ur Class-Accessor-0.34/lib/Class/Accessor.pm Class-Accessor-0.34-my/lib/Class/Accessor.pm
--- Class-Accessor-0.34/lib/Class/Accessor.pm 2009-09-15 20:16:41.000000000 +0400
+++ Class-Accessor-0.34-my/lib/Class/Accessor.pm 2010-05-10 20:26:14.000000000 +0400
@@ -4,13 +4,11 @@
$Class::Accessor::VERSION = '0.34';
sub new {
- my($proto, $fields) = @_;
- my($class) = ref $proto || $proto;
-
- $fields = {} unless defined $fields;
-
- # make a copy of $fields.
- bless {%$fields}, $class;
+ return bless
+ defined $_[1]
+ ? {%{$_[1]}} # make a copy of $fields.
+ : {},
+ ref $_[0] || $_[0];
}
sub mk_accessors {
Only in Class-Accessor-0.34-my/: pm_to_blib