(target: Pointer, minCap: number)
| 1086 | // --- Array Methods Support --- |
| 1087 | |
| 1088 | private arrayEnsureCapacity(target: Pointer, minCap: number) { |
| 1089 | this.resolvePtr(target.__ptr); |
| 1090 | if (this.scratchCap >= minCap) return; |
| 1091 | |
| 1092 | const oldCap = this.scratchCap; |
| 1093 | const oldLen = this.scratchLen; |
| 1094 | const oldDataStart = this.scratchStart; |
| 1095 | |
| 1096 | const newCap = Math.max(oldCap * 2, minCap); |
| 1097 | const newByteSize = 12 + newCap * 8; |
| 1098 | |
| 1099 | const newPtr = this.alloc(newByteSize); |
| 1100 | |
| 1101 | // Re-resolve after alloc |
| 1102 | this.resolvePtr(target.__ptr); |
| 1103 | |
| 1104 | const idx = newPtr >> 2; |
| 1105 | this.u32[idx] = TYPE_ARRAY; |
| 1106 | this.u32[idx + 1] = newCap; |
| 1107 | this.u32[idx + 2] = oldLen; |
| 1108 | |
| 1109 | // Copy existing data |
| 1110 | this.u8.set( |
| 1111 | this.u8.subarray(oldDataStart, oldDataStart + oldLen * 8), |
| 1112 | newPtr + 12, |
| 1113 | ); |
| 1114 | |
| 1115 | // Mark old as moved |
| 1116 | const pIdx = this.scratchPtr >> 2; |
| 1117 | this.u32[pIdx] = TYPE_MOVED; |
| 1118 | this.u32[pIdx + 1] = newPtr; |
| 1119 | |
| 1120 | this.resolvePtr(target.__ptr); |
| 1121 | } |
| 1122 | |
| 1123 | private arraySpliceImpl( |
| 1124 | target: Pointer, |
no test coverage detected