Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Let's assume we have a single field entity display object:
public function buildMultiple(array $entities) {
$build_list = array();
foreach ($entities as $key => $entity) {
$build_list[$key] = array();
}
// Run field formatters.
foreach ($this->getFieldDefinitions() as $field_name => $definition) {
if ($formatter = $this->getRenderer($field_name)) {
// Group items across all entities and pass them to the formatter's
// prepareView() method.
... So we still iterate over all field definitions, even we just render a single field.
Similar on a normal entity display rendering, we try it for all fields, even most fields are hidden.
Proposed resolution
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#2 | 2450151-optimize-EVD_build-2.patch | 3.27 KB | yched |
Comments
Comment #1
dawehner.
Comment #2
yched CreditAttribution: yched commentedHm - I guess we could loop on $this->content instead.
Attached patch does this,
+ adjust EntityFormDisplay accordingly for consistency,
+ unifies a couple var names while I'm in there
Comment #3
dawehnerLooks great!
This seems to save at least 3%, see https://blackfire.io/profiles/compare/1e808abb-fcb6-492e-adc1-2c404fff59...
Comment #4
dawehnerThe code changes looks great!
Comment #5
Wim LeersPatch looks clean & simple indeed :)
Comment #7
catchGood find. Committed/pushed to 8.0.x, thanks!