I did this one "off the clock" so I did have a little fun with a PHP Generator ;)
I saw a report that the resource repository was making thousands of DB queries and started to look into it. Fortunately, it looks like updating to the latest version with #2906539: Performance bug with references already took their uncached page loads from dozens of seconds to <10s. But I think we can do better!
In the current code, every call to ConfigurableResourceTypeRepository->get($entity_type_id, $bundle) calls ->getResourceTypes(FALSE), which means that the "cached" resource types are never used, which means the code will always load and process config. This fixes that.
Comments
Comment #2
e0ipsoThanks for the report and the patch! And thanks for reminding me that generators are a thing in PHP.
I think generators are cool, but we will never be able to take full advantage of them without an event look like ReactPHP's. For readability reasons (generators are a bit obscure) I've refactored to use regular arrays.
Comment #4
e0ipsoComment #5
gabesulliceHere's a nice trick:
This is good in PHP 5 too.
Comment #6
e0ipsoAh nice. I had it like that but I was too lazy to check php5. Thanks for the tip!
Comment #8
e0ipsoComment #9
e0ipsoWell, that comment didn't belong here.