Generate wrappers & use cgo hints#5
Closed
oliverbestmann wants to merge 5 commits into
Closed
Conversation
…ations to reduce memory allocation & cgo overhead
…ious implementation was capturing the generic runtime info when creating the closure passed to SetFinalizer. This is not necessary if we use an interface.
Owner
Author
|
@rcoreilly if you could have a quick look and check that nothing breaks on your side, that would be great. Otherwise I'll merge it later today or tomorrow and cleanup the pieces later :) |
rcoreilly
reviewed
May 29, 2026
|
|
||
| func (v stringView) Release() { | ||
| C.free(unsafe.Pointer(v.view.data)) | ||
| if v.view.data { |
There was a problem hiding this comment.
if v.view.data != nil
This doesn't even compile!
Owner
Author
There was a problem hiding this comment.
Yea I fixes that already. Sorry for that. One of those: "okay everything works. Let me create a PR. Wait, let me add this one if here and then push it"
|
Yep everything seems to work in cogentcore! |
Owner
Author
|
Thanks. I'll have a look at why it doesn't compile in Mac and wasm in ci later today and continue with the approach. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using #cgo noescape and #cgo nocallback when possible allows the go compiler to pass pointers to heap values. This leads to it not needing to allocate when calling into wgpu. It only needs to allocate once for the returned wrapper object.
Before:
After: