Skip to content

Commit 4708cb9

Browse files
karajasonaden
authored andcommitted
refactor(ivy): remove reserveSlots instruction (angular#25533)
PR Close angular#25533
1 parent 21d22ce commit 4708cb9

File tree

8 files changed

+281
-295
lines changed

8 files changed

+281
-295
lines changed

packages/core/src/render3/i18n.ts

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {assertEqual, assertLessThan} from './assert';
10-
import {NO_CHANGE, _getViewData, bindingUpdated, bindingUpdated2, bindingUpdated4, createLNode, getPreviousOrParentNode, getRenderer, load, resetApplicationState} from './instructions';
10+
import {NO_CHANGE, _getViewData, bindingUpdated, bindingUpdated2, bindingUpdated3, bindingUpdated4, createLNode, getPreviousOrParentNode, getRenderer, initBindings, load, resetApplicationState} from './instructions';
1111
import {RENDER_PARENT} from './interfaces/container';
1212
import {LContainerNode, LNode, TContainerNode, TElementNode, TNodeType} from './interfaces/node';
1313
import {BINDING_INDEX, HEADER_OFFSET, TVIEW} from './interfaces/view';
@@ -383,7 +383,8 @@ export function i18nExpMapping(
383383
* @returns The concatenated string when any of the arguments changes, `NO_CHANGE` otherwise.
384384
*/
385385
export function i18nInterpolation1(instructions: I18nExpInstruction[], v0: any): string|NO_CHANGE {
386-
const different = bindingUpdated(v0);
386+
initBindings();
387+
const different = bindingUpdated(_getViewData()[BINDING_INDEX]++, v0);
387388

388389
if (!different) {
389390
return NO_CHANGE;
@@ -414,7 +415,10 @@ export function i18nInterpolation1(instructions: I18nExpInstruction[], v0: any):
414415
*/
415416
export function i18nInterpolation2(instructions: I18nExpInstruction[], v0: any, v1: any): string|
416417
NO_CHANGE {
417-
const different = bindingUpdated2(v0, v1);
418+
initBindings();
419+
const viewData = _getViewData();
420+
const different = bindingUpdated2(viewData[BINDING_INDEX], v0, v1);
421+
viewData[BINDING_INDEX] += 2;
418422

419423
if (!different) {
420424
return NO_CHANGE;
@@ -452,8 +456,10 @@ export function i18nInterpolation2(instructions: I18nExpInstruction[], v0: any,
452456
*/
453457
export function i18nInterpolation3(
454458
instructions: I18nExpInstruction[], v0: any, v1: any, v2: any): string|NO_CHANGE {
455-
let different = bindingUpdated2(v0, v1);
456-
different = bindingUpdated(v2) || different;
459+
initBindings();
460+
const viewData = _getViewData();
461+
const different = bindingUpdated3(viewData[BINDING_INDEX], v0, v1, v2);
462+
viewData[BINDING_INDEX] += 3;
457463

458464
if (!different) {
459465
return NO_CHANGE;
@@ -493,7 +499,10 @@ export function i18nInterpolation3(
493499
*/
494500
export function i18nInterpolation4(
495501
instructions: I18nExpInstruction[], v0: any, v1: any, v2: any, v3: any): string|NO_CHANGE {
496-
const different = bindingUpdated4(v0, v1, v2, v3);
502+
initBindings();
503+
const viewData = _getViewData();
504+
const different = bindingUpdated4(viewData[BINDING_INDEX], v0, v1, v2, v3);
505+
viewData[BINDING_INDEX] += 4;
497506

498507
if (!different) {
499508
return NO_CHANGE;
@@ -535,8 +544,11 @@ export function i18nInterpolation4(
535544
export function i18nInterpolation5(
536545
instructions: I18nExpInstruction[], v0: any, v1: any, v2: any, v3: any, v4: any): string|
537546
NO_CHANGE {
538-
let different = bindingUpdated4(v0, v1, v2, v3);
539-
different = bindingUpdated(v4) || different;
547+
initBindings();
548+
const viewData = _getViewData();
549+
let different = bindingUpdated4(viewData[BINDING_INDEX], v0, v1, v2, v3);
550+
different = bindingUpdated(viewData[BINDING_INDEX] + 4, v4) || different;
551+
viewData[BINDING_INDEX] += 5;
540552

541553
if (!different) {
542554
return NO_CHANGE;
@@ -580,8 +592,11 @@ export function i18nInterpolation5(
580592
i18nInterpolation6(
581593
instructions: I18nExpInstruction[], v0: any, v1: any, v2: any, v3: any, v4: any, v5: any):
582594
string|NO_CHANGE {
583-
let different = bindingUpdated4(v0, v1, v2, v3);
584-
different = bindingUpdated2(v4, v5) || different;
595+
initBindings();
596+
const viewData = _getViewData();
597+
let different = bindingUpdated4(viewData[BINDING_INDEX], v0, v1, v2, v3);
598+
different = bindingUpdated2(viewData[BINDING_INDEX] + 4, v4, v5) || different;
599+
viewData[BINDING_INDEX] += 6;
585600

586601
if (!different) {
587602
return NO_CHANGE;
@@ -626,9 +641,11 @@ i18nInterpolation6(
626641
export function i18nInterpolation7(
627642
instructions: I18nExpInstruction[], v0: any, v1: any, v2: any, v3: any, v4: any, v5: any,
628643
v6: any): string|NO_CHANGE {
629-
let different = bindingUpdated4(v0, v1, v2, v3);
630-
different = bindingUpdated2(v4, v5) || different;
631-
different = bindingUpdated(v6) || different;
644+
initBindings();
645+
const viewData = _getViewData();
646+
let different = bindingUpdated4(viewData[BINDING_INDEX], v0, v1, v2, v3);
647+
different = bindingUpdated3(viewData[BINDING_INDEX] + 4, v4, v5, v6) || different;
648+
viewData[BINDING_INDEX] += 7;
632649

633650
if (!different) {
634651
return NO_CHANGE;
@@ -674,8 +691,11 @@ export function i18nInterpolation7(
674691
export function i18nInterpolation8(
675692
instructions: I18nExpInstruction[], v0: any, v1: any, v2: any, v3: any, v4: any, v5: any,
676693
v6: any, v7: any): string|NO_CHANGE {
677-
let different = bindingUpdated4(v0, v1, v2, v3);
678-
different = bindingUpdated4(v4, v5, v6, v7) || different;
694+
initBindings();
695+
const viewData = _getViewData();
696+
let different = bindingUpdated4(viewData[BINDING_INDEX], v0, v1, v2, v3);
697+
different = bindingUpdated4(viewData[BINDING_INDEX] + 4, v4, v5, v6, v7) || different;
698+
viewData[BINDING_INDEX] += 8;
679699

680700
if (!different) {
681701
return NO_CHANGE;
@@ -713,10 +733,12 @@ export function i18nInterpolation8(
713733
*/
714734
export function i18nInterpolationV(instructions: I18nExpInstruction[], values: any[]): string|
715735
NO_CHANGE {
736+
initBindings();
737+
const viewData = _getViewData();
716738
let different = false;
717739
for (let i = 0; i < values.length; i++) {
718740
// Check if bindings have changed
719-
bindingUpdated(values[i]) && (different = true);
741+
bindingUpdated(viewData[BINDING_INDEX]++, values[i]) && (different = true);
720742
}
721743

722744
if (!different) {

0 commit comments

Comments
 (0)