Skip to content

Commit f693be3

Browse files
karavicb
authored andcommitted
feat(ivy): add pureFunction0 instruction (angular#22214)
PR Close angular#22214
1 parent a73d530 commit f693be3

File tree

7 files changed

+350
-238
lines changed

7 files changed

+350
-238
lines changed

packages/core/src/core_render3_private_export.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export {
4444
pb3 as ɵpb3,
4545
pb4 as ɵpb4,
4646
pbV as ɵpbV,
47+
f0 as ɵf0,
4748
f1 as ɵf1,
4849
f2 as ɵf2,
4950
f3 as ɵf3,

packages/core/src/render3/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export {
7979
queryRefresh as qR,
8080
} from './query';
8181
export {
82+
pureFunction0 as f0,
8283
pureFunction1 as f1,
8384
pureFunction2 as f2,
8485
pureFunction3 as f3,

packages/core/src/render3/instructions.ts

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,16 +1749,54 @@ function valueInData<T>(data: any[], index: number, value?: T): T {
17491749
return value !;
17501750
}
17511751

1752-
/** Gets the binding at the current bindingIndex */
1753-
export function peekBinding(): any {
1754-
ngDevMode && assertNotEqual(currentView.bindingStartIndex, null, 'bindingStartIndex');
1755-
return data[bindingIndex];
1756-
}
1757-
17581752
export function getCurrentQueries(QueryType: {new (): LQueries}): LQueries {
17591753
return currentQueries || (currentQueries = new QueryType());
17601754
}
17611755

1756+
export function getCreationMode(): boolean {
1757+
return creationMode;
1758+
}
1759+
1760+
/** Gets the current binding value and increments the binding index. */
1761+
export function consumeBinding(): any {
1762+
ngDevMode && assertDataInRange(bindingIndex);
1763+
ngDevMode &&
1764+
assertNotEqual(data[bindingIndex], NO_CHANGE, 'Stored value should never be NO_CHANGE.');
1765+
return data[bindingIndex++];
1766+
}
1767+
1768+
/** Updates binding if changed, then returns whether it was updated. */
1769+
export function bindingUpdated(value: any): boolean {
1770+
ngDevMode && assertNotEqual(value, NO_CHANGE, 'Incoming value should never be NO_CHANGE.');
1771+
1772+
if (creationMode || isDifferent(data[bindingIndex], value)) {
1773+
creationMode && initBindings();
1774+
data[bindingIndex++] = value;
1775+
return true;
1776+
} else {
1777+
bindingIndex++;
1778+
return false;
1779+
}
1780+
}
1781+
1782+
/** Updates binding if changed, then returns the latest value. */
1783+
export function checkAndUpdateBinding(value: any): any {
1784+
bindingUpdated(value);
1785+
return value;
1786+
}
1787+
1788+
/** Updates 2 bindings if changed, then returns whether either was updated. */
1789+
export function bindingUpdated2(exp1: any, exp2: any): boolean {
1790+
const different = bindingUpdated(exp1);
1791+
return bindingUpdated(exp2) || different;
1792+
}
1793+
1794+
/** Updates 4 bindings if changed, then returns whether any was updated. */
1795+
export function bindingUpdated4(exp1: any, exp2: any, exp3: any, exp4: any): boolean {
1796+
const different = bindingUpdated2(exp1, exp2);
1797+
return bindingUpdated2(exp3, exp4) || different;
1798+
}
1799+
17621800
export function getPreviousOrParentNode(): LNode {
17631801
return previousOrParentNode;
17641802
}

0 commit comments

Comments
 (0)