diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2023-01-06 21:45:23 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-06 21:45:23 +0900 |
commit | ff89ff4abba39ce158056d390e761495f5a7bc86 (patch) | |
tree | 03a9c71b5bb3889842db06ed41c3999074c4107a /ext/webgpu/src/01_webgpu.js | |
parent | 39cbaa6d34c249afc4b197836da1fa6dd143cbf9 (diff) |
perf(ext,runtime): remove using `SafeArrayIterator` from `for-of` (#17255)
Diffstat (limited to 'ext/webgpu/src/01_webgpu.js')
-rw-r--r-- | ext/webgpu/src/01_webgpu.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/ext/webgpu/src/01_webgpu.js b/ext/webgpu/src/01_webgpu.js index 1c1b15756..02bdc6562 100644 --- a/ext/webgpu/src/01_webgpu.js +++ b/ext/webgpu/src/01_webgpu.js @@ -316,7 +316,8 @@ context: "Argument 1", }); const requiredFeatures = descriptor.requiredFeatures ?? []; - for (const feature of new SafeArrayIterator(requiredFeatures)) { + for (let i = 0; i < requiredFeatures.length; ++i) { + const feature = requiredFeatures[i]; if (!SetPrototypeHas(this[_adapter].features[_features], feature)) { throw new TypeError( `${prefix}: nonGuaranteedFeatures must be a subset of the adapter features.`, @@ -1046,14 +1047,16 @@ context: "Argument 1", }); const device = assertDevice(this, { prefix, context: "this" }); - for (const entry of new SafeArrayIterator(descriptor.entries)) { - let i = 0; - if (entry.buffer) i++; - if (entry.sampler) i++; - if (entry.texture) i++; - if (entry.storageTexture) i++; - - if (i !== 1) { + for (let i = 0; i < descriptor.entries.length; ++i) { + const entry = descriptor.entries[i]; + + let count = 0; + if (entry.buffer) count++; + if (entry.sampler) count++; + if (entry.texture) count++; + if (entry.storageTexture) count++; + + if (count !== 1) { throw new Error(); // TODO(@crowlKats): correct error } } @@ -1591,8 +1594,8 @@ device.rid, commandBufferRids, ); - for (const commandBuffer of new SafeArrayIterator(commandBuffers)) { - commandBuffer[_rid] = undefined; + for (let i = 0; i < commandBuffers.length; ++i) { + commandBuffers[i][_rid] = undefined; } device.pushError(err); } @@ -1934,7 +1937,8 @@ if (!mappedRanges) { throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } - for (const [buffer, _rid, start] of new SafeArrayIterator(mappedRanges)) { + for (let i = 0; i < mappedRanges.length; ++i) { + const [buffer, _rid, start] = mappedRanges[i]; // TODO(lucacasonato): is this logic correct? const end = start + buffer.byteLength; if ( @@ -2002,7 +2006,8 @@ if (!mappedRanges) { throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } - for (const [buffer, mappedRid] of new SafeArrayIterator(mappedRanges)) { + for (let i = 0; i < mappedRanges.length; ++i) { + const [buffer, mappedRid] = mappedRanges[i]; const { err } = ops.op_webgpu_buffer_unmap( bufferRid, mappedRid, |