Repository navigation
Conversation
Every controller connection refreshes the controllers declaring it as an outlet. Finding them listed the contexts of every controller in the application, even when no controller declares outlets, so connecting N controllers cost O(N²). Filter the modules by identifier first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Each time a controller connects, its
OutletObserver#startrefreshes the controllers that declare it as an outlet. To find them,dependentContextsfilteredrouter.contexts, which builds an array of every connected context of every controller, on every connection, even in an application where no controller declares an outlet. Connecting N controllers is therefore O(N²).dependentContextsnow filtersrouter.modulesby identifier first, then collects their contexts: the same contexts, in the same order, without walking the others. We noticed it on back-office pages of our app that hold more than 1,000 controllers; below a few hundred the difference is noise.The new test in
application_tests.tscounts reads ofrouter.contextswhile loading controllers, and fails onmain. Sibling PR: #926 makes the lookups behind outlets O(1).Measurements
Application#starton a page of N<div data-controller="row">, each with 2 targets, 2 values, 1 class and a button with 2 actions; no outlets.mainat 4145d26 and this branch, bundled with esbuild, Chrome 156 on an Apple Silicon Mac, median of 9 page loads.mainIs this an area you would like to see improved, or would you rather keep
OutletObserveras is for now?🤖 Generated with Claude Code, but prompted, read, and verified by @czj, a caring human :)