Repository navigation
Resolve the plugins path once per component in ComponentBase::getPath() - #1604
austinderrick wants to merge 1 commit into
Conversation
plugins_path() resolves the plugins directory segment by segment, checking each segment for a symlink, and ComponentPartial calls getPath() several times for every component partial it renders. Keep the resolved plugins path on the component, so each component instance resolves it once.
|
No actionable comments were generated in the recent review. WalkthroughComponentBase adds a protected property to store the plugins path. On the first call to getPath(), it resolves plugins_path() and stores the result. Later calls on the same component instance reuse the stored path when appending the component directory name. Estimated code review effort: 2 (Simple) | ~5 minutes Merge Risk:
|
ComponentBase::getPath()callsplugins_path(), which resolves the plugins directory one segment at a time with anis_link()and anis_file()check on each segment. Rendering one component partial callsgetPath()about four times throughComponentPartial::getFilePath(), so a page with a few components resolves the same directory hundreds of times per request. This change keeps the resolved path on the component instance, so each component resolves it once and nothing is kept between requests.PathResolver::resolve()callsis_link()calls fromresolve()resolve()Measured on a page with 6 components and the plugins directory 8 levels deep, on PHP 8.3 with OPcache and JIT, through a Laravel Octane worker. Paired on and off blocks in one process gave -3.3 ms (an A/A control gave -0.02 and -0.22 ms), 8 fresh-process rounds gave -2.9 ms, and a back-end form page showed no change.
Summary by CodeRabbit