1
0
mirror of https://github.com/theoludwig/kysely-typegen.git synced 2026-05-22 16:23:25 +02:00

perf: avoid O(n²) array spread in getEnumsMap accumulator

Mutate the existing values array instead of spreading it on every row.
This commit is contained in:
2026-05-22 10:33:08 +02:00
parent 77f520fce7
commit c025a63c8c
+6 -1
View File
@@ -173,7 +173,12 @@ export class KyselyTypegenPostgresDialect extends KyselyTypegenDialect {
const enums = new Map<string, string[]>()
for (const row of rows) {
const data = row as { enumName: string; enumValue: string }
enums.set(data.enumName, [...(enums.get(data.enumName) ?? []), data.enumValue])
const existing = enums.get(data.enumName)
if (existing == null) {
enums.set(data.enumName, [data.enumValue])
} else {
existing.push(data.enumValue)
}
}
return enums
}