Skip to content

Commit

Permalink
Merge pull request #1387 from soyuka/fix/cache-denormalization
Browse files Browse the repository at this point in the history
In memory cache for supportsDenormalization types
  • Loading branch information
dunglas committed Sep 21, 2017
2 parents 3e08f29 + 7d6352f commit c3c380e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Serializer/AbstractItemNormalizer.php
Expand Up @@ -43,6 +43,7 @@ abstract class AbstractItemNormalizer extends AbstractObjectNormalizer
protected $iriConverter;
protected $resourceClassResolver;
protected $propertyAccessor;
protected $localCache = [];

public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, IriConverterInterface $iriConverter, ResourceClassResolverInterface $resourceClassResolver, PropertyAccessorInterface $propertyAccessor = null, NameConverterInterface $nameConverter = null, ClassMetadataFactoryInterface $classMetadataFactory = null)
{
Expand Down Expand Up @@ -99,7 +100,7 @@ public function normalize($object, $format = null, array $context = [])
*/
public function supportsDenormalization($data, $type, $format = null)
{
return $this->resourceClassResolver->isResourceClass($type);
return $this->localCache[$type] ?? $this->localCache[$type] = $this->resourceClassResolver->isResourceClass($type);
}

/**
Expand Down

0 comments on commit c3c380e

Please sign in to comment.