New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
builtins.concatStringsSep: Guarantee amortised O(n) #3942
Conversation
What if we made another C++ |
Answering #3941 (comment):
There's no C++ standard guarantee for it: https://en.cppreference.com/w/cpp/string/basic_string/operator%2B%3D:
The amortised-constant guarantee that the standard gives for GCC's So it's more of a "do you want to code against API guarantees or implementation details" choice. This PR guarantees the complexity relying only on what the standard says. It would also be OK to rely on the implementation but I think that should have a comment then. (For my memory, and in contrast to what I believed before, |
I don't think we need to worry too much about theoretical implementations not doing the sane thing. Having said that, it would be nice to avoid doing any reallocations, but then we should evaluate each string, sum the sizes and BTW another optimization that might be worthwhile is to avoid allocating the temporary strings returned by |
OK, I shall switch it then to just a comment that says why it's not quadratic on the platforms we use.
@edolstra How should that best be done? There seem to be 2 straightforward ways:
|
The second option should be fine since they're temporary strings anyway and probably not very large. |
I marked this as stale due to inactivity. → More info |
I closed this issue due to inactivity. → More info |
Hold up, fine if stale bot is marking things stale, but it should be closing them. We need to actually triage old stuff. We can't just let a bot due our duties for us. I assume this was just a misconfiguration, as the Nixpkgs stale bot doesn't close things to my knowledge. |
It looks like It also closed some other PRs that I think really shouldn't be closed: #3208 (comment) |
Fixes #3941 (comment).