refactor(ivy): name LQuery object for easier memory allocation tracking (#30656)
PR Close #30656
This commit is contained in:
parent
b61784948a
commit
8e8c1ad47d
|
@ -58,35 +58,35 @@ export interface QueryPredicate<T> {
|
||||||
* - values collected based on a predicate
|
* - values collected based on a predicate
|
||||||
* - `QueryList` to which collected values should be reported
|
* - `QueryList` to which collected values should be reported
|
||||||
*/
|
*/
|
||||||
export interface LQuery<T> {
|
class LQuery<T> {
|
||||||
|
constructor(
|
||||||
/**
|
/**
|
||||||
* Next query. Used when queries are stored as a linked list in `LQueries`.
|
* Next query. Used when queries are stored as a linked list in `LQueries`.
|
||||||
*/
|
*/
|
||||||
next: LQuery<any>|null;
|
public next: LQuery<any>|null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destination to which the value should be added.
|
* Destination to which the value should be added.
|
||||||
*/
|
*/
|
||||||
list: QueryList<T>;
|
public list: QueryList<T>,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A predicate which determines if a given element/directive should be included in the query
|
* A predicate which determines if a given element/directive should be included in the query
|
||||||
* results.
|
* results.
|
||||||
*/
|
*/
|
||||||
predicate: QueryPredicate<T>;
|
public predicate: QueryPredicate<T>,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Values which have been located.
|
* Values which have been located.
|
||||||
*
|
|
||||||
* This is what builds up the `QueryList._valuesTree`.
|
* This is what builds up the `QueryList._valuesTree`.
|
||||||
*/
|
*/
|
||||||
values: any[];
|
public values: any[],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pointer to an array that stores collected values from views. This is necessary so we know a
|
* A pointer to an array that stores collected values from views. This is necessary so we
|
||||||
* container into which to insert nodes collected from views.
|
* know a container into which to insert nodes collected from views.
|
||||||
*/
|
*/
|
||||||
containerValues: any[]|null;
|
public containerValues: any[]|null) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LQueries_ implements LQueries {
|
export class LQueries_ implements LQueries {
|
||||||
|
@ -145,14 +145,7 @@ function copyQueriesToContainer(query: LQuery<any>| null): LQuery<any>|null {
|
||||||
while (query) {
|
while (query) {
|
||||||
const containerValues: any[] = []; // prepare room for views
|
const containerValues: any[] = []; // prepare room for views
|
||||||
query.values.push(containerValues);
|
query.values.push(containerValues);
|
||||||
const clonedQuery: LQuery<any> = {
|
result = new LQuery<any>(result, query.list, query.predicate, containerValues, null);
|
||||||
next: result,
|
|
||||||
list: query.list,
|
|
||||||
predicate: query.predicate,
|
|
||||||
values: containerValues,
|
|
||||||
containerValues: null
|
|
||||||
};
|
|
||||||
result = clonedQuery;
|
|
||||||
query = query.next;
|
query = query.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,14 +156,7 @@ function copyQueriesToView(query: LQuery<any>| null): LQuery<any>|null {
|
||||||
let result: LQuery<any>|null = null;
|
let result: LQuery<any>|null = null;
|
||||||
|
|
||||||
while (query) {
|
while (query) {
|
||||||
const clonedQuery: LQuery<any> = {
|
result = new LQuery<any>(result, query.list, query.predicate, [], query.values);
|
||||||
next: result,
|
|
||||||
list: query.list,
|
|
||||||
predicate: query.predicate,
|
|
||||||
values: [],
|
|
||||||
containerValues: query.values
|
|
||||||
};
|
|
||||||
result = clonedQuery;
|
|
||||||
query = query.next;
|
query = query.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,13 +335,9 @@ function createPredicate<T>(predicate: Type<T>| string[], read: Type<T>| null):
|
||||||
function createLQuery<T>(
|
function createLQuery<T>(
|
||||||
previous: LQuery<any>| null, queryList: QueryList<T>, predicate: Type<T>| string[],
|
previous: LQuery<any>| null, queryList: QueryList<T>, predicate: Type<T>| string[],
|
||||||
read: Type<T>| null): LQuery<T> {
|
read: Type<T>| null): LQuery<T> {
|
||||||
return {
|
return new LQuery(
|
||||||
next: previous,
|
previous, queryList, createPredicate(predicate, read),
|
||||||
list: queryList,
|
(queryList as any as QueryList_<T>)._valuesTree, null);
|
||||||
predicate: createPredicate(predicate, read),
|
|
||||||
values: (queryList as any as QueryList_<T>)._valuesTree,
|
|
||||||
containerValues: null
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type QueryList_<T> = QueryList<T>& {_valuesTree: any[], _static: boolean};
|
type QueryList_<T> = QueryList<T>& {_valuesTree: any[], _static: boolean};
|
||||||
|
|
Loading…
Reference in New Issue