util: concatStringsSep(): Avoid quadratic string append#3941
util: concatStringsSep(): Avoid quadratic string append#3941nh2 wants to merge 1 commit intoNixOS:masterfrom
Conversation
|
I also noticed that the Lines 2113 to 2120 in e849b19 If a nix language user uses Could we use the same approach there, computing Edit: See PR #3942. |
|
Doesn't std::string grow the capacity by a constant factor when it exceeds the current capacity, thereby amortizing the cost to O(1) per character? |
Many implementations do, but the standard doesn't guarantee it, see full answer in #3942 (comment). |
|
I marked this as stale due to inactivity. → More info |
|
I closed this issue due to inactivity. → More info |
Repeated
+=makes no complexity guarantees; this does.I also renamed the variables for some more clarity (to be aligned with the docs of the function).