Mercurial > pub > Impl
diff Lib/IMPL/Web/QueryHandler/JsonFormat.pm @ 134:44977efed303
Significant performance optimizations
Fixed recursion problems due converting objects to JSON
Added cache support for the templates
Added discovery feature for the web methods
author | wizard |
---|---|
date | Mon, 21 Jun 2010 02:39:53 +0400 |
parents | 08753833173d |
children | fb896377389f |
line wrap: on
line diff
--- a/Lib/IMPL/Web/QueryHandler/JsonFormat.pm Fri Jun 18 16:27:28 2010 +0400 +++ b/Lib/IMPL/Web/QueryHandler/JsonFormat.pm Mon Jun 21 02:39:53 2010 +0400 @@ -30,6 +30,13 @@ use base qw(IMPL::Transform); use IMPL::Class::Property; +use IMPL::Class::Property::Direct; +use Scalar::Util qw(refaddr); + +BEGIN { + private _direct property _visited => prop_none; +} + my %propListCache; our %CTOR = ( @@ -89,4 +96,17 @@ } ); +sub Transform { + my ($this,$object) = @_; + + return $this->SUPER::Transform($object) unless ref $object; + + if (exists $this->{$_visited}{refaddr $object}) { + return $this->{$_visited}{refaddr $object}; + } else { + $this->{$_visited}{refaddr $object} = undef; + return $this->{$_visited}{refaddr $object} = $this->SUPER::Transform($object); + } +} + 1; \ No newline at end of file