Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance: Skip iteration in block supports elements when not neces…
…sary. Previously there have been three ways in which the block supports elements code has been performing computation it doesn't need to. - It checks for every possible style attribute on a block even if there are no possible style attributes available on the block. - Once it determines that it needs to add a special class to a block it continues scanning through the rest of the attributes. - It constructs dot-separated literal key paths for the attributes and immediately and repeatedly calls `explode()` on them to create an array at runtime. The combination of these three factors leads to an outsized impact of this function on the runtime and memory pressure for what it's doing. This patch removes all three of these inefficiencies: - If no elements style attributes exist on the block it immediately returns and skips all further processing. - It stops scanning block attributes once a single one is found that imposes the requirement for the extra class name. - It constructs array literals for the key path instead of strings. This removes the need to artificially join and explode the keys at runtime. There should be no functional or visual changes in this patch, but it should reduce the overall runtime of page renders and require less memory while rendering. The impact will be proportional to the number of blocks rendered on a page.
- Loading branch information