Skip to content

Consistently use #[inline] in font-types #490

@cmyr

Description

@cmyr

This attribute is poorly documented and inconsistently used, but potentially important.

For some more information, see rust-lang/hashbrown#119 (comment).

The TL;DR is that #[inline] has two tasks: within a crate, it functions as a hint. Between crate boundaries, though, it is required in order for inlining to be possible at all.

This last point is particularly important in the font-types crate; it contains lots of small methods, which are really only called from external crates. In many cases, the code produced by inlining these functions is not going to be much larger than the code required to setup and execute a function call.

Based on this, I suspect that the majority of the small functions in font-types should be marked #[inline]; and this should definitely be true of functions like the get methods on BigEndian.

The downside of this is that each crate that uses font-types will end up with a separate copy of these functions. I believe that these should ultimately be deduplicated, but it will minorly impact compile times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions