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

Report information
The Basics
Id:
6749
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
maurice [...] redweek.com
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
3.0.3
Fixed in:
(no value)



Subject: redundant calls to make_accessor()
Class::DBI 0.96 perl 5.8.0 Linux 2.4.20 When creating the column accessors in _mk_column_accessors, if the set and get methods have the same name (i.e., mutator_name is not overridden), make_accessor() is called twice for the same accessor. That's cause %method always has two keys, 'ro' and 'wo,' that we iterate over even when $both is true. The patch modifies %method in the case where the names match, causing make_accessor() to only be called once.
--- lib/Class/DBI.pm.orig 2004-06-24 10:52:02.000000000 -0700 +++ lib/Class/DBI.pm 2004-06-24 10:53:02.000000000 -0700 @@ -383,13 +383,13 @@ my $class = shift; foreach my $obj ($class->_find_columns(@_)) { my %method = ( - ro => $obj->accessor($class->accessor_name($obj->name)), - wo => $obj->mutator($class->mutator_name($obj->name)), + _ro => $obj->accessor($class->accessor_name($obj->name)), + _wo => $obj->mutator($class->mutator_name($obj->name)), ); - my $both = ($method{ro} eq $method{wo}); + %method = ('' => $method{_ro}) if $method{_ro} eq $method{_wo}; foreach my $type (keys %method) { my $name = $method{$type}; - my $acc_type = $both ? "make_accessor" : "make_${type}_accessor"; + my $acc_type = "make${type}_accessor"; my $accessor = $class->$acc_type($obj->name_lc); $class->_make_method($_, $accessor) for ($name, "_${name}_accessor"); }
Date: Thu, 24 Jun 2004 23:03:20 +0100
From: Tony Bowden <tony@kasei.com>
To: Maurice_Aubrey via RT <bug-Class-DBI@rt.cpan.org>
Subject: Re: [cpan #6749] redundant calls to make_accessor()
RT-Send-Cc:
On Thu, Jun 24, 2004 at 03:19:55PM -0400, Maurice_Aubrey via RT wrote:
Show quoted text
> When creating the column accessors in _mk_column_accessors, > if the set and get methods have the same name (i.e., mutator_name is not > overridden), make_accessor() is called twice for the same accessor. > The patch modifies %method in the case where the names match, > causing make_accessor() to only be called once.
Is this causing a problem, or this is merely an optimisation? Tony
Show quoted text
> |>make_accessor() is called twice for the same accessor. > | Is this causing a problem, or this is merely an optimisation? > Just an optimisation, and low priority at that since it only affects > start-up cost.
Thanks for this. Fixed in 3.0.3 which is on CPAN now. Tony


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.