[Jifty-commit] r849 - in Jifty-DBI/trunk: lib/Jifty/DBI lib/Jifty/DBI/Record

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed Apr 12 21:14:11 EDT 2006


Author: jesse
Date: Wed Apr 12 21:14:10 2006
New Revision: 849

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/Changes
   Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm

Log:
 r11590 at hualien:  jesse | 2006-04-12 21:13:30 -0400
 * __value performance improvement for the common case.


Modified: Jifty-DBI/trunk/Changes
==============================================================================
--- Jifty-DBI/trunk/Changes	(original)
+++ Jifty-DBI/trunk/Changes	Wed Apr 12 21:14:10 2006
@@ -1,5 +1,6 @@
 Revision history for Perl extension Jifty::DBI.
 
+* Performance optimization for the "standard case" of __value
 * Postgres sequence parsing fix from Daniel Tabuenca
 
 0.19 Sun Apr  2 18:59:53 JST 2006

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	Wed Apr 12 21:14:10 2006
@@ -460,12 +460,17 @@
 
 sub __value {
     my $self        = shift;
-    my $column_name = shift;
+    my $column_name = lc(shift);
+
+    # In the default case of "yeah, we have a value", return it as
+    # fast as we can.
+    return   $self->{'values'}{$column_name}
+        if ( $self->{'fetched'}{$column_name}
+          && $self->{'decoded'}{$column_name} );
 
     # If the requested column is actually an alias for another, resolve it.
     if ( $self->column($column_name)
-        and defined $self->column($column_name)->alias_for_column )
-    {
+        and defined $self->column($column_name)->alias_for_column ) {
         $column_name = $self->column($column_name)->alias_for_column();
     }
 
@@ -473,8 +478,6 @@
 
     return unless ($column);
 
-    #Carp::confess unless ($column);
-
     if ( !$self->{'fetched'}{ $column->name } and my $id = $self->id() ) {
         my $pkey         = $self->_primary_key();
         my $query_string = "SELECT "

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm	Wed Apr 12 21:14:10 2006
@@ -192,13 +192,13 @@
 
 }
 
-sub __value {
-    my $self   = shift;
-    my $column = shift;
-
-    # XXX TODO, should we be fetching directly from the cache?
-    return ( $self->SUPER::__value($column) );
-}
+#sub __value {
+#    my $self   = shift;
+#    my $column = shift;
+#
+#    # XXX TODO, should we be fetching directly from the cache?
+#    return ( $self->SUPER::__value($column) );
+#}
 
 # Function: _store
 # Type    : private instance


More information about the Jifty-commit mailing list