-
Notifications
You must be signed in to change notification settings - Fork 57
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
Cache Class::get
#65
Comments
I'm working on a macro that caches the lookup, but @grovesNL it's worth noting you can avoid the lookup entirely and link the class. Like this: extern {
#[link_name = "OBJC_CLASS_$_NSObject"]
static OBJC_CLASS: Class;
}
let cls = unsafe { &OBJC_CLASS } Unfortunately I can't do that with a declarative macro because there's no way to use inputs to the macro inside the link directive. But it's doable with a procedural macro, and I've got a different macro working in objc-foundation-derive that does this. |
@SSheldon The new macro looks great. We'll try it out soon, thanks! |
61: Cache class access r=kvark a=grovesNL - Uses [objc's new `class` macro](SSheldon/rust-objc#65) to cache all class accesses - Bumps the crate version to 0.10.3 Co-authored-by: Joshua Groves <[email protected]>
Use new objc class macro This PR removes the `class` function in favor of the [new `class` macro exposed by objc](SSheldon/rust-objc#65) which caches access by class name. Note that this macro should eventually (through procedural macros) be able to link directly to the class. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/226) <!-- Reviewable:end -->
Currently gfx spends a significant amount of time calling
Class::get
.Similarly to #64, would it be possible to cache these calls somehow? Perhaps there could be a macro that provides this, like
class!("NSObject")
.We could try to add this to metal-rs directly for the places we need it (example), but we also need this change in other crates (for example, we frequently create
NSAutoreleasePool
), so it would be great if we could find a way to add this into objc.cc @kvark @jrmuizel
The text was updated successfully, but these errors were encountered: