-
-
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
Dereferencing result of cast
in single expression triggers unnecessary copy
#24093
Comments
I don't understand how "Dereference operator never copies" can be a reasonable requirement. |
In that case the copy comes effectively comes from the |
Correct but then that's exactly where the copy comes from in the |
Ordinary |
Description
Here, the first
block
/for
loop triggers a whole-array copy:i.e. the
for
loop constructs thecolontmp_
variable as the object to loop over, given:By contrast, splitting that apart a bit:
results in:
Which does not have any copies. This is with
--mm:orc
;--mm:refc
has a similar pattern but with,refc
details, wherefor _ in cast[typeof(a)](a)[]:
triggers a copy andlet x = cast[typeof(a)](a)
/for _ in x[]:
doesn't.Nim Version
Current Output
Expected Output
Known Workarounds
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: