[Jifty-commit] r6593 - in Jifty-DBI/trunk: lib/Jifty/DBI
Jifty commits
jifty-commit at lists.jifty.org
Tue Mar 17 10:54:22 EDT 2009
Author: alexmv
Date: Tue Mar 17 10:54:20 2009
New Revision: 6593
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
Log:
r43260 at kohr-ah: chmrr | 2009-03-17 10:53:30 -0400
Provide a faster load_from_hash for when we're being called from do_search
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm Tue Mar 17 10:54:20 2009
@@ -209,7 +209,7 @@
$row->{ substr($_, 5) } = delete $row->{ $_ }
foreach grep rindex($_, "main_", 0) == 0, keys %$row;
my $item = $self->new_item;
- $item->load_from_hash($row);
+ $item->load_from_hash($row, fast => 1);
$self->add_record($item);
}
if ( $records->err ) {
@@ -242,7 +242,7 @@
my $item;
foreach my $row ( values %{ $data->{$row_id}->{'main'} } ) {
$item = $self->new_item();
- $item->load_from_hash($row);
+ $item->load_from_hash($row, fast => 1);
}
foreach my $alias ( grep { $_ ne 'main' } keys %{ $data->{$row_id} } )
{
@@ -260,7 +260,7 @@
derived => 1 );
foreach my $row (@rows) {
my $entry = $collection->new_item;
- $entry->load_from_hash($row);
+ $entry->load_from_hash($row, fast => 1);
$collection->add_record($entry);
}
@@ -269,7 +269,7 @@
warn "Multiple rows returned for $class in prefetch"
if @rows > 1;
my $entry = $class->new( $self->_new_record_args );
- $entry->load_from_hash( shift @rows ) if @rows;
+ $entry->load_from_hash( shift(@rows), fast => 1 ) if @rows;
$item->prefetched( $col_name => $entry );
} else {
Carp::cluck(
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 Tue Mar 17 10:54:20 2009
@@ -1186,6 +1186,15 @@
sub load_from_hash {
my $self = shift;
my $hashref = shift;
+ my %args = @_;
+ if ($args{fast}) {
+ # Optimization for loading from database
+ $self->{values} = $hashref;
+ $self->{fetched}{$_} = 1 for keys %{$hashref};
+ $self->{raw_values} = {};
+ $self->{decoded} = {};
+ return $self->{values}{id};
+ }
unless ( ref $self ) {
$self = $self->new( handle => delete $hashref->{'_handle'} );
More information about the Jifty-commit
mailing list