Skip to content

Commit 3787021

Browse files
committed
Keep keyed-list runtime native for embedded builds
Avoid nullable pending-bulk carriers and exact scalar equalities that expanded into enormous structural casts in generated headers. This reduced the e-reader rescue header enough for Xtensa GCC and preserved keyed-list behavior through the successful firmware build.
1 parent 8ddcf0d commit 3787021

6 files changed

Lines changed: 15 additions & 16 deletions

File tree

packages/gea/src/runtime/delegate-event.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ export function delegateEvent(root: Element, type: string, pairs: HandlerPair[],
6767
}
6868
}
6969
},
70-
_NON_BUBBLING[type] === true,
70+
!!_NON_BUBBLING[type],
7171
)
7272
}
7373
for (let i = 0; i < pairs.length; i++) {
7474
const el = pairs[i][0]
7575
if (el) {
76-
if (pairs[i][2] === false) {
76+
if (!pairs[i][2]) {
7777
;(el as any)[k] = pairs[i][1]
7878
} else {
7979
;(el as any)[currentTargetKey] = pairs[i][1]

packages/gea/src/runtime/keyed-list-prop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function keyedListProp(cfg: PropKeyedListConfig): void {
9696
}
9797
}
9898

99-
if (aipuOnly && changes!.length === 2) {
99+
if (aipuOnly && changes!.length > 1 && changes!.length < 3) {
100100
const a = changes![0].arix as number
101101
const b = changes![1].arix as number
102102
if (a >= 0 && b >= 0 && a < entries.length && b < entries.length && a !== b) {
@@ -177,7 +177,7 @@ export function keyedListProp(cfg: PropKeyedListConfig): void {
177177
totalRemoved += (change.count as number) || 0
178178
}
179179
if (onlyRemoves && entries.length - arr.length === totalRemoved) {
180-
if (changes.length === 1 && (changes[0].count as number) === 1) {
180+
if (changes.length < 2 && (changes[0].count as number) === 1) {
181181
const idx = changes[0].start as number
182182
if (idx >= 0 && idx < entries.length) {
183183
removeEntry(entries[idx])

packages/gea/src/runtime/keyed-list-simple.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function keyedListSimple(cfg: SimpleKeyedListConfig): void {
112112
}
113113
}
114114

115-
if (aipuOnly && changes!.length === 2) {
115+
if (aipuOnly && changes!.length > 1 && changes!.length < 3) {
116116
const a = changes![0].arix as number
117117
const b = changes![1].arix as number
118118
if (a >= 0 && b >= 0 && a < entries.length && b < entries.length && a !== b) {
@@ -193,7 +193,7 @@ export function keyedListSimple(cfg: SimpleKeyedListConfig): void {
193193
totalRemoved += (change.count as number) || 0
194194
}
195195
if (onlyRemoves && entries.length - arr.length === totalRemoved) {
196-
if (changes.length === 1 && (changes[0].count as number) === 1) {
196+
if (changes.length < 2 && (changes[0].count as number) === 1) {
197197
const idx = changes[0].start as number
198198
if (idx >= 0 && idx < entries.length) {
199199
removeEntry(entries[idx])

packages/gea/src/runtime/keyed-list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export function keyedList(cfg: KeyedListConfig): void {
194194
}
195195
}
196196
// aipu-only 2-swap: items[i]↔items[j] via two symmetric aipu records.
197-
if (aipuOnly && changes!.length === 2) {
197+
if (aipuOnly && changes!.length > 1 && changes!.length < 3) {
198198
const a = changes![0].arix as number
199199
const b = changes![1].arix as number
200200
if (a >= 0 && b >= 0 && a < entries.length && b < entries.length && a !== b) {
@@ -282,7 +282,7 @@ export function keyedList(cfg: KeyedListConfig): void {
282282
totalRemoved += (c.count as number) || 0
283283
}
284284
if (onlyRemoves && entries.length - arr.length === totalRemoved) {
285-
if (changes.length === 1 && (changes[0].count as number) === 1) {
285+
if (changes.length < 2 && (changes[0].count as number) === 1) {
286286
const idx = changes[0].start as number
287287
if (idx >= 0 && idx < entries.length) {
288288
removeEntry(entries[idx])

packages/gea/src/runtime/keyed-list/lis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function lis(arr: number[]): number[] {
1010
const vals: number[] = []
1111
const idxs: number[] = []
1212
for (let i = 0; i < n; i++) {
13-
if (arr[i] !== -1) {
13+
if (arr[i] >= 0) {
1414
vals.push(arr[i])
1515
idxs.push(i)
1616
}

packages/gea/src/runtime/keyed-list/rescue.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const _toFlush = new Set<Pending>()
2424
const _live = new WeakMap<Pending, LiveEntries>()
2525
const _claimed = new WeakSet<Entry>()
2626
const _claimable = new WeakSet<Entry>()
27-
let _pendingBulk: PendingBulkBatch[] | null = null
27+
let _pendingBulk: PendingBulkBatch[] = []
2828
let _flushQueued = false
2929

3030
const _unwrap = (v: any): any => (v && typeof v === 'object' && v[GEA_PROXY_RAW]) || v
@@ -74,7 +74,7 @@ function _schedule(): void {
7474
const drainMaps = Array.from(_toFlush)
7575
const bulk = _pendingBulk
7676
_toFlush.clear()
77-
_pendingBulk = null
77+
_pendingBulk = []
7878
for (let i = 0; i < drainMaps.length; i++) {
7979
const m = drainMaps[i]
8080
for (const e of m.values()) {
@@ -86,7 +86,7 @@ function _schedule(): void {
8686
}
8787
m.clear()
8888
}
89-
if (bulk) {
89+
if (bulk.length > 0) {
9090
for (let i = 0; i < bulk.length; i++) {
9191
const batch = bulk[i].entries
9292
for (let j = 0; j < batch.length; j++) {
@@ -125,8 +125,7 @@ export function _deferBulk(pending: Pending, entries: Entry[]): void {
125125
}
126126
if (next.length === 0) return
127127
const batch: PendingBulkBatch = { pending, entries: next }
128-
if (_pendingBulk) _pendingBulk.push(batch)
129-
else _pendingBulk = [batch]
128+
_pendingBulk.push(batch)
130129
_schedule()
131130
}
132131

@@ -140,15 +139,15 @@ export function _rescue(pending: Pending, key: string, item?: any): Entry | null
140139
// Lazy fallback: materialize any pending bulk batches into their target
141140
// pending maps so cross-site rescue still works without paying per-row
142141
// Map.set on the common no-rescue-needed bulk path.
143-
if (_pendingBulk) {
142+
if (_pendingBulk.length > 0) {
144143
for (let i = 0; i < _pendingBulk.length; i++) {
145144
const batch = _pendingBulk[i]
146145
const target = batch.pending
147146
const items = batch.entries
148147
for (let j = 0; j < items.length; j++) target.set(String(items[j].key), items[j])
149148
_toFlush.add(target)
150149
}
151-
_pendingBulk = null
150+
_pendingBulk = []
152151
const r = pending.get(key)
153152
if (r) {
154153
pending.delete(key)

0 commit comments

Comments
 (0)