-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
newString
zeroes memory contrary to its documentation, significantly slowing it down
#22555
Comments
Isn't it potentially a potential runtime breaking change supposing someone relies on the quirky behaviour? Yeah, let's find out whether it breaks something. |
It breaks jangko/nimPNG#85 |
But aren't all Nim data structures supposed to be zero-initialized? I think the correct least-surprising way forward is to introduce newStringUninit / newStringUninitialized. |
Hmm good point. |
Came to a similar conclusion while thinking about it over the weekend ( but to complete this section of nim, #19727 really needs addressing as well - the current situation is silly, ie can't |
As you wish, I will add a new function and remove outdated documentation. |
Hi, @arnetheduck, |
It's a good enough to start with - I can imagine a few cases where this is too strict as well but it's easy to further relax in the future - ie consider a |
* fixes newStringUninitialized; implement `newStringUninitialized` * add a simple test case * adds a changelog * Update lib/system.nim * Apply suggestions from code review rename to newStringUninit
Description
newString
is supposed to return an uninitialized string, and thus presumably be fast:Nim/lib/system.nim
Line 976 in d677ed3
However, the actual implementations zero the full string leading to significant overhead making the function unfit for its purpose:
https://github.com/nim-lang/Nim/blob/devel/lib/system/strs_v2.nim#L113
Nim Version
1.6, devel, both refc and orc
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: