-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Add local cache to normalizers #24228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ inline Serializer::denormalizeObject()
?
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supportsNormalization($data, $format = null) | ||
{ | ||
return parent::supportsNormalization($data, $format) && $this->supports(get_class($data)); | ||
return parent::supportsNormalization($data, $format) && (isset($this->cache[$type = \get_class($data)]) ? $this->cache[$type] : $this->cache[$type] = $this->supports($type)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applies to supportsDenormalization as well, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about private static $cache
+ private static supports()
+ inline isGetMethod
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supportsNormalization($data, $format = null) | ||
{ | ||
return parent::supportsNormalization($data, $format) && $this->supports(get_class($data)); | ||
return parent::supportsNormalization($data, $format) && (isset($this->cache[$type = \get_class($data)]) ? $this->cache[$type] : $this->cache[$type] = $this->supports($type)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
6e94152
to
44dd0ad
Compare
Done. |
44dd0ad
to
a0fe606
Compare
@@ -66,7 +66,7 @@ public function denormalize($data, $class, $format = null, array $context = arra | |||
*/ | |||
public function supportsDenormalization($data, $type, $format = null/*, array $context = array()*/) | |||
{ | |||
$context = func_num_args() > 3 ? func_get_arg(3) : array(); | |||
$context = \func_num_args() > 3 ? func_get_arg(3) : array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0fdab2f
to
23f485e
Compare
23f485e
to
b0c5cf0
Compare
Won't it make sense to backport what could be on lower branches? |
AFAIK, we merge perf improvements as new feats usually (even if we diverged sometime from this rule, but we shouldn't anymore unless catastrophic. Not sure it's the case here?) |
…kas) This PR was merged into the 3.4 branch. Discussion ---------- [Serializer] Add local cache to normalizers | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24206 | License | MIT | Doc PR | - Should help making the Serializer a bit faster. Commits ------- b0c5cf0 [Serializer] Add local cache to normalizers
Should help making the Serializer a bit faster.