Description
Description
I dug a lot it Symfony internals lastly and the name converter stack was very costly. I reduced it a lot with #35041... Then I realized than I don't need at all a name converter.
The default one is MetadataAwareNameConverter, that allow a fallbackNameConverter. But the fallback is called ONLY after having grab all the metadata, checked for a SerializerName
. I never saw a project using this attribute, and it troubles me that it costs so much. So just giving a simpler NameConverter as fallback is not enough because the worse already happened.
I tried another way: replacing MetadataAwareNameConverter completely. It seems to work flawlessly and gives me a 11% performance improvement (AFTER the previously mentioned patch, so more than a 25% gain from master)
<?php
namespace Lib\Core\Serializer\NameConverter;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
/**
* Do nothing name converter
*/
class NullNameConverter implements NameConverterInterface
{
public function normalize($propertyName)
{
return $propertyName;
}
public function denormalize($propertyName)
{
return $propertyName;
}
}
services:
serializer.name_converter.metadata_aware: '@Lib\Core\Serializer\NameConverter\NullNameConverter'
Questions:
- Did I miss something that I could break with that?
- Should a simpler Name Converter should be added in Symfony?
- Should it be the default? Or as least purposed by default
- Maybe add a pass somewhere "hi you are not using any
SerializerName
and you didn't provide a NameConverter fallback, switching to NullNameConverter"?