-
-
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
add overload add(a: var string, b: openArray[char])
#15951
add overload add(a: var string, b: openArray[char])
#15951
Conversation
a96cf06
to
47773e9
Compare
While the intention here is good there are so many things in the stdlib that could benefit from using a more generic char sequence type (like in strutils) and openarray[char] is not the best candidate, lest we snowball into doing this everywhere. This change is however small and mirrors add(var seq[T], openarray[T]), so it's fine, except that that overload doesn't copy memory directly and uses move/sink instead |
A snowball has to start somewhere... 😼 |
string/seq/array implicitly converts to openArray[char], which is the main point; I'm not sure what your other "best candidate" is (apart from std/views see #14869 which has the advantage of being 1st class but doesn't implicitly convert from string/seq/array; only explicitly)
for openArray[char] (this PR) memcpy (or memmove if memory overlaps) is the correct thing to do; for the other existing overload with seq[T], we could/should do the same depending on |
a32d472
to
9104ef3
Compare
Can we add this to the new |
99fc861
to
c1649ac
Compare
done I'll followup with a PR to address this:
with some refactoring from compiler/strutils2 |
a73a474
to
69a3270
Compare
d658a9d
to
d9245a1
Compare
Co-authored-by: Andreas Rumpf <[email protected]>
Co-authored-by: Andreas Rumpf <[email protected]>
2 goals:
y
openArray to begin withfuture work
https://github.com/nim-lang/Nim/pull/15421/files#r522703485
addCstringN
add(a: var string, b: openArray[char])
#15951 (comment) (see also follow up #15951 #17478)