3 ms·
No, they won't in standard implementations we are not exactly allocating, the allocated buffer doubles each time, so it's amortised and not O(n^2). There is a d
by eklavya 5y ago
No, they won't in standard implementations we are not exactly allocating, the allocated buffer doubles each time, so it's amortised and not O(n^2). There is a downside for non trivial example code.
- Dylan16807 5y agoEvery add except the first one is using the same code in either version. The suggested change does not affect String + &str at all.
- eklavya 5y agoOk, maybe I misunderstood, I thought you were saying &str + &str with precomputed capacity in call cases, let me read it again.