Repository navigation
Conversation
…template names already resolved `Environment::getTemplateClass()` calls the loader's `getCacheKey()` on every `include`, `embed`, `extends` and `import`. `ChainLoader` asked each loader `exists()` again, and `FilesystemLoader` normalized the name and stripped the root path again. Both loaders now remember the key per template name. The memo is cleared where the existing caches are cleared (`addLoader()`, `addPath()`, `prependPath()`). `getTemplateClass()` goes from 531-542 -> 312-319 ns with a `FilesystemLoader`, and 876-947 -> 316-320 ns behind a `ChainLoader`. A page with 500 includes goes from 1.275-1.319 -> 0.997-1.060 ms. Caveat: like the existing `$hasSourceCache`, the `ChainLoader` memo does not see a sub-loader changed after the fact (`$chain->getLoaders()[0]->addPath()`), and a `FilesystemLoader` subclass that empties the protected `$cache` by hand keeps the old key.
nicolas-grekas
approved these changes
Nov 15, 2026
GromNaN
approved these changes
Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Environment::getTemplateClass()calls the loader'sgetCacheKey()on everyinclude,embed,extendsandimport.ChainLoaderasked each loaderexists()again, andFilesystemLoadernormalized the name and stripped the root path again.Both loaders now remember the key per template name. The memo is cleared where the existing caches are cleared (
addLoader(),addPath(),prependPath()).getTemplateClass()goes from 531-542 -> 312-319 ns with aFilesystemLoader, and 876-947 -> 316-320 ns behind aChainLoader. A page with 500 includes goes from 1.275-1.319 -> 0.997-1.060 ms. Caveat: like the existing$hasSourceCache, theChainLoadermemo does not see a sub-loader changed after the fact ($chain->getLoaders()[0]->addPath()), and aFilesystemLoadersubclass that empties the protected$cacheby hand keeps the old key.