Skip to content

Commit f0e1d49

Browse files
committed
fix: 🐛 correct capacity estimator tuple handling
1 parent 0af529d commit f0e1d49

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/codegen/capacity/CapacityEstimatorCodegen.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ export class CapacityEstimatorCodegen extends AbstractCodegen<CompiledCapacityEs
9191
const {_head = [], _type, _tail = []} = type;
9292
const headLength = _head.length;
9393
const tailLength = _tail.length;
94-
// const tupleLength = headLength + tailLength;
95-
// if (tupleLength) {
96-
// codegen.if(/* js */ `${rLen} < ${tupleLength}`, () => {
97-
// codegen.js(/* js */ `throw new Error('INV_LEN');`);
98-
// });
99-
// }
10094
if (_type) {
10195
const isConstantSizeType = _type instanceof ConType || _type instanceof BoolType || _type instanceof NumType;
10296
if (isConstantSizeType) {
@@ -106,7 +100,7 @@ export class CapacityEstimatorCodegen extends AbstractCodegen<CompiledCapacityEs
106100
: _type instanceof BoolType
107101
? MaxEncodingOverhead.Boolean
108102
: MaxEncodingOverhead.Number;
109-
codegen.js(/* js */ `size += ${rLen} * ${elementSize};`);
103+
codegen.js(/* js */ `size += (${rLen} - ${headLength + tailLength}) * ${elementSize};`);
110104
} else {
111105
const rv = codegen.var(r.use());
112106
const ri = codegen.getRegister();

0 commit comments

Comments
 (0)