From 09092a13b6fdb153d7760e840335336c321ec005 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Thu, 29 Apr 2010 11:35:04 -0500 Subject: [PATCH] performance enhancement --- lib/WebGUI/Asset.pm | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 801af9fc6..48406cc9b 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1825,11 +1825,7 @@ no revision date is available it will return undef. =cut sub new { - my $class = shift; - my $session = shift; - my $assetId = shift; - my $className = shift; - my $revisionDate = shift; + my ( $class, $session, $assetId, $className, $revisionDate ) = @_; unless (defined $assetId) { $session->errorHandler->error("Asset constructor new() requires an assetId."); @@ -1867,18 +1863,19 @@ sub new { $session->errorHandler->error("Asset $assetId $class $revisionDate is missing properties. Consult your database tables for corruption. "); return undef; } + # Deserialize + foreach my $definition (@{ $class->definition($session) }) { + foreach my $property (keys %{ $definition->{properties} }) { + if ($definition->{properties}->{$property}->{serialize} && $properties->{$property} ne '') { + $properties->{$property} = JSON->new->canonical->decode($properties->{$property}); + } + } + } $cache->set($properties,60*60*24); } if (defined $properties) { my $object = { _session=>$session, _properties => $properties }; bless $object, $class; - foreach my $definition (@{ $object->definition($session) }) { - foreach my $property (keys %{ $definition->{properties} }) { - if ($definition->{properties}->{$property}->{serialize} && $object->{_properties}->{$property} ne '') { - $object->{_properties}->{$property} = JSON->new->canonical->decode($object->{_properties}->{$property}); - } - } - } return $object; } $session->errorHandler->error("Something went wrong trying to instanciate a '$className' with assetId '$assetId', but I don't know what!");