The implementation of mapValues in the typescript-fetch runtime currently takes O(n^2) time relative to the number of keys (n) in the data object. This is due to the use of the spread operator ... within the reduce callback, which copies the entire accumulated object on every iteration.
Problem code:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache#L335-L340
return Object.keys(data).reduce(
(acc, key) => ({ ...acc, [key]: fn(data[key]) }),
{}
);
Impact:
This inefficiency can lead to noticeable performance degradation in generated clients.
Proposed solution:
Use a simple loop with direct assignment to improve the performance. I will put up a PR shortly with the proposed fix.
The implementation of
mapValuesin thetypescript-fetchruntime currently takes O(n^2) time relative to the number of keys (n) in thedataobject. This is due to the use of the spread operator...within thereducecallback, which copies the entire accumulated object on every iteration.Problem code:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache#L335-L340
Impact:
This inefficiency can lead to noticeable performance degradation in generated clients.
Proposed solution:
Use a simple loop with direct assignment to improve the performance. I will put up a PR shortly with the proposed fix.