Skip Menu |

This queue is for tickets about the Class-DBI CPAN distribution.

Report information
The Basics
Id: 59574
Status: new
Priority: 0/
Queue: Class-DBI

People
Owner: Nobody in particular
Requestors: adam.prime [...] utoronto.ca
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: v3.0.17
Fixed in: (no value)



Subject: [PATCH] Optimization for Class::DBI::Column
I doing some optimization at $work i've been trying to speed up some operations that make a lot of accessor hits, to the point that the top exclusive time in nytprof is name_lc in Class::DBI::Column. The attached patch makes Class:DBI::Column's cache the lowercased version of their name rather than compute it on the fly. It also makes it so that if the columns name is ever updated, that the name_lc is kept in sync. there hasn't been much (any?) testing done on this, i've just run it in my little test app thing and it was a significant improvement and didn't cause any explosions. If there's actually a sliver of hope that this will get in and released i'd be more than willing to write some tests for it.
Subject: CDBI.patch
--- lib/site_perl/Class/DBI/Column.pm 2010-07-20 16:07:57.472873202 -0400 +++ /home/aprime/Column.pm 2010-07-20 16:07:05.579941724 -0400 @@ -30,7 +30,7 @@ use Carp; __PACKAGE__->mk_accessors( - qw/name accessor mutator placeholder is_constrained/ + qw/accessor mutator placeholder is_constrained/ ); use overload @@ -52,6 +52,7 @@ return $class->SUPER::new( { name => $name, + name_lc => lc $name, accessor => $name, mutator => $name, _groups => {}, @@ -61,7 +62,14 @@ ); } -sub name_lc { lc shift->name } +sub name { + return $_[0]->{'name'} if scalar(@_) == 1; + my $ret = $_[0]->{'name'} = scalar(@_) == 2 ? $_[1] : [@_[1..$#_]]; + $_[0]->{'name_lc'} = lc $_[0]->name; + return $ret; +} + +sub name_lc { shift->{name_lc} } sub add_group { my ($self, $group) = @_;