Specify weight in _field_tokens $display_options to avoid calculating max weight

Created on 6 August 2025, 10 days ago

Problem/Motivation

I was doing some performance debugging of field_group and noticed performance dings in field_group_field_info_max_weight due to the max weight being calculated in EntityDisplayBase.

Token causes this to be invoked when viewing the field since $display_options doesn't provide a weight. Providing a weight avoids \Drupal\Core\Entity\EntityDisplayBase::getHighestWeight from being called and invoking that hook. It's a performance improvement for field value rendering.

Steps to reproduce

Proposed resolution

Provide a weight of 0

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024