rust-objc icon indicating copy to clipboard operation
rust-objc copied to clipboard

API for passing already nul-terminated strings to avoid allocation

Open SSheldon opened this issue 8 years ago • 1 comments

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 avatar Feb 05 '17 21:02 SSheldon

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.

SSheldon avatar Apr 30 '17 20:04 SSheldon