-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Labels
Description
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.
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.
mix4242