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/fetch | |
parent | 39cbaa6d34c249afc4b197836da1fa6dd143cbf9 (diff) |
perf(ext,runtime): remove using `SafeArrayIterator` from `for-of` (#17255)
Diffstat (limited to 'ext/fetch')
-rw-r--r-- | ext/fetch/20_headers.js | 6 | ||||
-rw-r--r-- | ext/fetch/21_formdata.js | 16 |
2 files changed, 15 insertions, 7 deletions
diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index a2fae2cfe..54e635522 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -68,7 +68,8 @@ */ function fillHeaders(headers, object) { if (ArrayIsArray(object)) { - for (const header of new SafeArrayIterator(object)) { + for (let i = 0; i < object.length; ++i) { + const header = object[i]; if (header.length !== 2) { throw new TypeError( `Invalid header. Length must be 2, but is ${header.length}`, @@ -205,7 +206,8 @@ // spec but produce the same result. const headers = {}; const cookies = []; - for (const entry of new SafeArrayIterator(list)) { + for (let i = 0; i < list.length; ++i) { + const entry = list[i]; const name = byteLowerCase(entry[0]); const value = entry[1]; if (value === null) throw new TypeError("Unreachable"); diff --git a/ext/fetch/21_formdata.js b/ext/fetch/21_formdata.js index ad3986874..4ab955610 100644 --- a/ext/fetch/21_formdata.js +++ b/ext/fetch/21_formdata.js @@ -25,7 +25,6 @@ MathRandom, ObjectPrototypeIsPrototypeOf, Symbol, - SafeArrayIterator, StringFromCharCode, StringPrototypeTrim, StringPrototypeSlice, @@ -163,7 +162,9 @@ context: "Argument 1", }); - for (const entry of new SafeArrayIterator(this[entryList])) { + const entries = this[entryList]; + for (let i = 0; i < entries.length; ++i) { + const entry = entries[i]; if (entry.name === name) return entry.value; } return null; @@ -184,7 +185,9 @@ }); const returnList = []; - for (const entry of new SafeArrayIterator(this[entryList])) { + const entries = this[entryList]; + for (let i = 0; i < entries.length; ++i) { + const entry = entries[i]; if (entry.name === name) ArrayPrototypePush(returnList, entry.value); } return returnList; @@ -204,7 +207,9 @@ context: "Argument 1", }); - for (const entry of new SafeArrayIterator(this[entryList])) { + const entries = this[entryList]; + for (let i = 0; i < entries.length; ++i) { + const entry = entries[i]; if (entry.name === name) return true; } return false; @@ -374,7 +379,8 @@ #parseHeaders(headersText) { const headers = new Headers(); const rawHeaders = StringPrototypeSplit(headersText, "\r\n"); - for (const rawHeader of new SafeArrayIterator(rawHeaders)) { + for (let i = 0; i < rawHeaders.length; ++i) { + const rawHeader = rawHeaders[i]; const sepIndex = StringPrototypeIndexOf(rawHeader, ":"); if (sepIndex < 0) { continue; // Skip this header |