[Jifty-commit] r1249 - in Jifty-DBI/trunk: lib/Jifty/DBI
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Jun 10 22:49:24 EDT 2006
Author: jesse
Date: Sat Jun 10 22:49:23 2006
New Revision: 1249
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
Log:
r12485 at pinglin: jesse | 2006-06-10 22:48:24 -0400
* Caching for columns and readable/writable attributes. Only gains us 2% performance. But hey. 2% free
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm Sat Jun 10 22:49:23 2006
@@ -17,6 +17,9 @@
Jifty::DBI::Record->mk_classdata(qw/COLUMNS/);
Jifty::DBI::Record->mk_classdata(qw/TABLE_NAME/ );
+Jifty::DBI::Record->mk_classdata(qw/_READABLE_COLS_CACHE/);
+Jifty::DBI::Record->mk_classdata(qw/_WRITABLE_COLS_CACHE/);
+Jifty::DBI::Record->mk_classdata(qw/_COLUMNS_CACHE/ );
=head1 NAME
@@ -321,8 +324,14 @@
my $self = shift;
my $name = shift;
$name = lc $name;
+
+
+
$self->COLUMNS->{$name} = Jifty::DBI::Column->new()
unless exists $self->COLUMNS->{$name};
+ $self->_READABLE_COLS_CACHE(undef);
+$self->_WRITABLE_COLS_CACHE(undef);
+$self->_COLUMNS_CACHE(undef );
$self->COLUMNS->{$name}->name($name);
return $self->COLUMNS->{$name};
}
@@ -343,14 +352,17 @@
sub columns {
my $self = shift;
- return (
+ return @{$self->_COLUMNS_CACHE() || $self->_COLUMNS_CACHE([
sort {
( ( ( $b->type || '' ) eq 'serial' )
<=> ( ( $a->type || '' ) eq 'serial' ) )
or ( ($a->sort_order || 0) <=> ($b->sort_order || 0))
or ( $a->name cmp $b->name )
} values %{ $self->COLUMNS }
- );
+
+
+ ])}
+
}
# sub {{{ readable_attributes
@@ -363,7 +375,7 @@
sub readable_attributes {
my $self = shift;
- return sort map { $_->name } grep { $_->readable } $self->columns;
+ return @{$self->_READABLE_COLS_CACHE() || $self->_READABLE_COLS_CACHE([sort map { $_->name } grep { $_->readable } $self->columns])};
}
=head2 writable_attributes
@@ -375,7 +387,7 @@
sub writable_attributes {
my $self = shift;
- return sort map { $_->name } grep { $_->writable } $self->columns;
+ return @{$self->_WRITABLE_COLS_CACHE() || $self->_WRITABLE_COLS_CACHE([sort map { $_->name } grep { $_->writable } $self->columns])};
}
=head2 record values
More information about the Jifty-commit
mailing list