Mercurial > pub > Impl
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 133:a07a66fd8d5c | 134:44977efed303 |
|---|---|
| 28 | 28 |
| 29 package IMPL::Transform::Json; | 29 package IMPL::Transform::Json; |
| 30 | 30 |
| 31 use base qw(IMPL::Transform); | 31 use base qw(IMPL::Transform); |
| 32 use IMPL::Class::Property; | 32 use IMPL::Class::Property; |
| 33 use IMPL::Class::Property::Direct; | |
| 34 use Scalar::Util qw(refaddr); | |
| 35 | |
| 36 BEGIN { | |
| 37 private _direct property _visited => prop_none; | |
| 38 } | |
| 39 | |
| 33 my %propListCache; | 40 my %propListCache; |
| 34 | 41 |
| 35 our %CTOR = ( | 42 our %CTOR = ( |
| 36 'IMPL::Transform' => sub { | 43 'IMPL::Transform' => sub { |
| 37 ARRAY => sub { | 44 ARRAY => sub { |
| 87 }; | 94 }; |
| 88 } | 95 } |
| 89 } | 96 } |
| 90 ); | 97 ); |
| 91 | 98 |
| 99 sub Transform { | |
| 100 my ($this,$object) = @_; | |
| 101 | |
| 102 return $this->SUPER::Transform($object) unless ref $object; | |
| 103 | |
| 104 if (exists $this->{$_visited}{refaddr $object}) { | |
| 105 return $this->{$_visited}{refaddr $object}; | |
| 106 } else { | |
| 107 $this->{$_visited}{refaddr $object} = undef; | |
| 108 return $this->{$_visited}{refaddr $object} = $this->SUPER::Transform($object); | |
| 109 } | |
| 110 } | |
| 111 | |
| 92 1; | 112 1; |
