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

ReferenceAccessor should be a factory #47

Closed
SebastianStehle opened this issue Oct 8, 2023 · 1 comment
Closed

ReferenceAccessor should be a factory #47

SebastianStehle opened this issue Oct 8, 2023 · 1 comment
Assignees

Comments

@SebastianStehle
Copy link
Collaborator

SebastianStehle commented Oct 8, 2023

The reference accessor is actually super weird. First, an object is created. Then we check the handle and discard this object again. This puts unnecessary pressure on the GC.

I think we should just rename it to ReferenceFactory and refactor it to methods like this:

public static Output? Output(nint handle, bool shouldDispose)
{
     return handle == nint.Zero ? null : new Output(handle, shouldDispose);
}

Depending on #48 it might event be obsolete.

Please assign me, if you agree. Happy to provide a PR.

@LSViana
Copy link
Collaborator

LSViana commented Oct 13, 2023

Hi, @SebastianStehle!

I like this idea. I'm not completely happy with ReferenceAccessor because it's just static code to centralize some operations but I didn't put a lot of thought here. It could be better.

However, let's finish #48 first then we discuss what to do here.

@LSViana LSViana self-assigned this Oct 13, 2023
@LSViana LSViana closed this as completed Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants