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

API for passing already nul-terminated strings to avoid allocation #54

Open
SSheldon opened this issue Feb 5, 2017 · 1 comment
Open

Comments

@SSheldon
Copy link
Owner

SSheldon commented Feb 5, 2017

Currently, in the runtime and declare modules, the API takes &str for ease of use. However, this requires copying the string into a buffer and adding a nul terminator byte. It might be desirable for some cases to have a way to pass in strings which are already known to be nul-terminated so that this allocation can be avoided.

@SSheldon
Copy link
Owner Author

Exploring some options here and created the nul crate.

Currently conflicted on whether that's the best solution. I'm realizing that really, the only strings that need to be provided are names (of classes, ivars, methods, etc). We could make an even nicer macro for generating those because they're idents. Maybe something like name!(NSObject) instead of ntstr!("NSObject"). At that point, is a separate crate even worth it? Or should we just have an objc::Name struct for encapsulating this.

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

1 participant