improvement(serializer,3.x): cache requested (de-)serializations#53
improvement(serializer,3.x): cache requested (de-)serializations#53brutal-factories wants to merge 4 commits intoliip:3.xfrom
Conversation
…know everything is initialized and loaded
dbu
left a comment
There was a problem hiding this comment.
thanks for looking into this. did you measure the difference that the cache makes? because of require_once, i don't see that we would save much work with a cache.
| throw UnsupportedTypeException::typeUnsupportedDeserialization($type); | ||
| } | ||
| require_once $filename; | ||
| // todo: index cache by function name instead of type when deserializing with groups/versions is supported |
There was a problem hiding this comment.
could you use the result of DeserializerGenerator::buildDeserializerFunctionName as cache key?
There was a problem hiding this comment.
I can, and the future of this function should be that, I took the shortcut when it seemed available, since without groups/versions, the function name will necessarily be a one-to-one with the type
There was a problem hiding this comment.
I ended up putting my timings on the 2.x version : #52 (comment)
| } | ||
| require_once $filename; | ||
| // todo: index cache by function name instead of type when deserializing with groups/versions is supported | ||
| if (isset($this->cachedDeserializers[$type])) { |
There was a problem hiding this comment.
i prefer array_key_exists - it is a bit more robust as e.g. isset would just return false instead of error if the cachedDeserializers property does not exist.
|
i merged the result of #52 into the 3.x branch, so this improvement is now in the newly released 3.3.0 |
What's in this PR?
Improvement to Serializer's objectToArray and arrayToObject: cache all loaded (de-)serializers. This PR targets the 3.x, like #52 targets the 2.x
Checklist