Skip to content
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

unsafe.Add for arrays #34

Closed
TotallyGamerJet opened this issue Sep 12, 2021 · 2 comments · Fixed by #40
Closed

unsafe.Add for arrays #34

TotallyGamerJet opened this issue Sep 12, 2021 · 2 comments · Fixed by #40
Assignees
Labels
enhancement New feature or request

Comments

@TotallyGamerJet
Copy link
Contributor

Do we want to start using unsafe.Add for arrays? It will make the code shorter and potentially easier to read. It would, however, require that we push the version of the compiler to 1.17 and all resulting code would use that version too.
Example:

var Ptr *int
Ptr = (*int)(unsafe.Pointer(uintptr(unsafe.Pointer(Ptr)) + uintptr(Len)))

Now becomes:

var Ptr *int
Ptr = (*int)(unsafe.Add(unsafe.Pointer(Ptr)), Len)
@dennwc
Copy link
Contributor

dennwc commented Sep 13, 2021

Definitely! But as you mentioned, I would either prefer to wait a bit, or add an option to cxgo.yml to use old behavior.

@dennwc dennwc added the enhancement New feature or request label Sep 13, 2021
@dennwc
Copy link
Contributor

dennwc commented Nov 14, 2021

The time has come! I think it's safe to move on without adding it to options. Code definitely looks better with it.

@dennwc dennwc self-assigned this Nov 14, 2021
dennwc added a commit that referenced this issue Nov 14, 2021
@dennwc dennwc mentioned this issue Nov 14, 2021
dennwc added a commit that referenced this issue Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants