Skip to content

Make selector! macro zero-cost #2

@nvzqz

Description

@nvzqz

Currently, the selector! macro calls Sel::register, which in turn calls sel_registerName. This is inefficient compared to @selector in Objective-C.

On my machine, I measure:

Initial Subsequent
Low 2.15µs 100ns
High 2.45µs 210ns

This is relatively small compared to objc_msgSend. However, one of the goals of this crate is to be zero-cost compared to the same code written directly in Objective-C.

Related issues:


I made an attempt in nvzqz/rust-selector-example, however it fails to build at link time. See that repo for details.

The culprit seems to be the literal_pointers link option. It builds fine with just __DATA,__objc_selrefs, but I get "unrecognized selector" when trying to use the selector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions