diff --git a/packages/client-generator-js/src/GenericsArgsInfo.ts b/packages/client-generator-js/src/GenericsArgsInfo.ts index f52417fcf76a..4518bd31dccf 100644 --- a/packages/client-generator-js/src/GenericsArgsInfo.ts +++ b/packages/client-generator-js/src/GenericsArgsInfo.ts @@ -26,7 +26,9 @@ export class GenericArgsInfo { const toVisit: ToVisitItem[] = [{ type: topLevelType }] const visited = new Set() let item: ToVisitItem | undefined - while ((item = toVisit.shift())) { + // read the queue by index: it grows to hundreds of thousands of items and `shift()` is linear in its length + let head = 0 + while ((item = toVisit[head++])) { const { type: currentType } = item const cached = this._cache.get(currentType) if (cached === true) { diff --git a/packages/client-generator-ts/src/GenericsArgsInfo.ts b/packages/client-generator-ts/src/GenericsArgsInfo.ts index f52417fcf76a..4518bd31dccf 100644 --- a/packages/client-generator-ts/src/GenericsArgsInfo.ts +++ b/packages/client-generator-ts/src/GenericsArgsInfo.ts @@ -26,7 +26,9 @@ export class GenericArgsInfo { const toVisit: ToVisitItem[] = [{ type: topLevelType }] const visited = new Set() let item: ToVisitItem | undefined - while ((item = toVisit.shift())) { + // read the queue by index: it grows to hundreds of thousands of items and `shift()` is linear in its length + let head = 0 + while ((item = toVisit[head++])) { const { type: currentType } = item const cached = this._cache.get(currentType) if (cached === true) {