When in the process of increasing performance of our application, I noticed two things:
- fetched Definitions are not (locally) cached, for instance in a local array property
$acquiredDefinitions[$name] => $definition
- array_key_exists() is used, while isset() tends to perform better, although:
- it is considered a micro-optimization...
- when the value equals
NULL it will be considered 'not set'
What do you think? Would a PR on this make sense? It can be as easy as:
private function getDefinition($name)
{
if(!array_key_exists($name, $this->acquiredDefinitions)){
$this->acquiredDefinitions[$name] = $this->definitionSource->getDefinition($name);
}
return $this->acquiredDefinitions[$name];
}
Maybe $lookedUpDefinitions or $fetchedDefinitions is a better name for the property...
Attached a part of a BlackFire.io profiling session of the current situation.

Adding this local cache reduces the amount of lookups with around 390 calls.