Skip to content

Commit 2fe6f35

Browse files
pkozlowski-opensourcejasonaden
authored andcommitted
refactor(ivy): avoid repeated read of LView from global state (angular#30587)
PR Close angular#30587
1 parent 514ebf4 commit 2fe6f35

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/core/src/render3/query.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,10 @@ type QueryList_<T> = QueryList<T>& {_valuesTree: any[], _static: boolean};
368368
* @param read What to save in the query
369369
* @returns QueryList<T>
370370
*/
371-
export function query<T>(
371+
function query<T>(
372372
// TODO: "read" should be an AbstractType (FW-486)
373-
predicate: Type<any>| string[], descend: boolean, read: any): QueryList<T> {
373+
lView: LView, predicate: Type<any>| string[], descend: boolean, read: any): QueryList<T> {
374374
ngDevMode && assertPreviousIsParent(getIsParent());
375-
const lView = getLView();
376375
const queryList = new QueryList<T>() as QueryList_<T>;
377376
const queries = lView[QUERIES] || (lView[QUERIES] = new LQueries_(null, null, null));
378377
queryList._valuesTree = [];
@@ -443,7 +442,7 @@ export function ɵɵviewQuery<T>(
443442
tView.expandoStartIndex++;
444443
}
445444
const index = getCurrentQueryIndex();
446-
const viewQuery: QueryList<T> = query<T>(predicate, descend, read);
445+
const viewQuery: QueryList<T> = query<T>(lView, predicate, descend, read);
447446
store(index - HEADER_OFFSET, viewQuery);
448447
setCurrentQueryIndex(index + 1);
449448
return viewQuery;
@@ -478,7 +477,7 @@ export function ɵɵcontentQuery<T>(
478477
read: any): QueryList<T> {
479478
const lView = getLView();
480479
const tView = lView[TVIEW];
481-
const contentQuery: QueryList<T> = query<T>(predicate, descend, read);
480+
const contentQuery: QueryList<T> = query<T>(lView, predicate, descend, read);
482481
(lView[CONTENT_QUERIES] || (lView[CONTENT_QUERIES] = [])).push(contentQuery);
483482
if (tView.firstTemplatePass) {
484483
const tViewContentQueries = tView.contentQueries || (tView.contentQueries = []);

0 commit comments

Comments
 (0)