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

Builders should store a SmallVec<[(&'static str, Value)]> #1391

Closed
jf2048 opened this issue Oct 22, 2022 · 2 comments
Closed

Builders should store a SmallVec<[(&'static str, Value)]> #1391

jf2048 opened this issue Oct 22, 2022 · 2 comments

Comments

@jf2048
Copy link
Member

jf2048 commented Oct 22, 2022

This would significantly reduce the stack size of the builder, and would not cause any extra overhead since Object::new_internal has to do this anyway. The builders can also unsafely call new_internal to avoid checks, since we know they only use valid properties.

After that, the builders could be made generic and the property setters could be moved into extension traits, which would cut down on a lot of the duplicated generated code.

@sdroege
Copy link
Member

sdroege commented Oct 23, 2022

The builders can also unsafely call new_internal to avoid checks, since we know they only use valid properties.

That's not actually what it does. The only thing it doesn't do is checking whether the type implements GInitable or GAsyncInitable.

This would significantly reduce the stack size of the builder

It would actually increase the stack size or not? Right now it's just allocated on the heap in a Vec. But it gets rid of a useless heap allocation in many cases.

Actually, I was thinking that we could make use of the generic ObjectBuilder for the specific builders. But that would go against your idea of omitting the property validity checks as that one always would have to do that.

@jf2048
Copy link
Member Author

jf2048 commented Feb 7, 2023

Fixed by #1431

@jf2048 jf2048 closed this as completed Feb 7, 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