Skip to content

Mark some derived methods as #[inline]. #10557

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

Closed
wants to merge 1 commit into from

Conversation

huonw
Copy link
Member

@huonw huonw commented Nov 19, 2013

ToStr, Encodable and Decodable are not marked as such, since they're
already expensive, and lead to large methods, so inlining will bloat the
metadata & the binaries.

This means that something like

#[deriving(Eq)]
struct A { x: int }

creates an instance like

#[doc = "Automatically derived."]
impl ::std::cmp::Eq for A {
    #[inline]
    fn eq(&self, __arg_0: &A) -> ::bool {
        match *__arg_0 {
            A{x: ref __self_1_0} =>
            match *self {
                A{x: ref __self_0_0} => true && __self_0_0.eq(__self_1_0)
            }
        }
    }
    #[inline]
    fn ne(&self, __arg_0: &A) -> ::bool {
        match *__arg_0 {
            A{x: ref __self_1_0} =>
            match *self {
                A{x: ref __self_0_0} => false || __self_0_0.ne(__self_1_0)
            }
        }
    }
}

(The change being the #[inline] attributes.)

ToStr, Encodable and Decodable are not marked as such, since they're
already expensive, and lead to large methods, so inlining will bloat the
metadata & the binaries.

This means that something like

    #[deriving(Eq)]
    struct A { x: int }

creates an instance like

    #[doc = "Automatically derived."]
    impl ::std::cmp::Eq for A {
        #[inline]
        fn eq(&self, __arg_0: &A) -> ::bool {
            match *__arg_0 {
                A{x: ref __self_1_0} =>
                match *self {
                    A{x: ref __self_0_0} => true && __self_0_0.eq(__self_1_0)
                }
            }
        }
        #[inline]
        fn ne(&self, __arg_0: &A) -> ::bool {
            match *__arg_0 {
                A{x: ref __self_1_0} =>
                match *self {
                    A{x: ref __self_0_0} => false || __self_0_0.ne(__self_1_0)
                }
            }
        }
    }

(The change being the `#[inline]` attributes.)
bors added a commit that referenced this pull request Nov 19, 2013
ToStr, Encodable and Decodable are not marked as such, since they're
already expensive, and lead to large methods, so inlining will bloat the
metadata & the binaries.

This means that something like

    #[deriving(Eq)]
    struct A { x: int }

creates an instance like

    #[doc = "Automatically derived."]
    impl ::std::cmp::Eq for A {
        #[inline]
        fn eq(&self, __arg_0: &A) -> ::bool {
            match *__arg_0 {
                A{x: ref __self_1_0} =>
                match *self {
                    A{x: ref __self_0_0} => true && __self_0_0.eq(__self_1_0)
                }
            }
        }
        #[inline]
        fn ne(&self, __arg_0: &A) -> ::bool {
            match *__arg_0 {
                A{x: ref __self_1_0} =>
                match *self {
                    A{x: ref __self_0_0} => false || __self_0_0.ne(__self_1_0)
                }
            }
        }
    }

(The change being the `#[inline]` attributes.)
@bors bors closed this Nov 19, 2013
@huonw huonw deleted the inline-deriving branch November 25, 2013 10:56
mbrubeck added a commit to mbrubeck/servo that referenced this pull request Apr 30, 2014
This code did not use derived traits previously because their methods were not
inlined, but this was fixed in rust-lang/rust#10557.
bors-servo pushed a commit to servo/servo that referenced this pull request Apr 30, 2014
This code did not use derived traits previously because their methods were not inlined, but this was fixed in rust-lang/rust#10557. r? @pcwalton
Manishearth pushed a commit to Manishearth/servo that referenced this pull request May 2, 2014
This code did not use derived traits previously because their methods were not
inlined, but this was fixed in rust-lang/rust#10557.
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Sep 30, 2019
…y-cleanup); r=Ms2ger

This code did not use derived traits previously because their methods were not inlined, but this was fixed in rust-lang/rust#10557. r? pcwalton

Source-Repo: https://github.com/servo/servo
Source-Revision: 8af9ce07f8ec9dddc926c1f76ade9e84427034db

UltraBlame original commit: de3f2703b11e0d467bf92c052904cb1cfd484a9c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Sep 30, 2019
…y-cleanup); r=Ms2ger

This code did not use derived traits previously because their methods were not inlined, but this was fixed in rust-lang/rust#10557. r? pcwalton

Source-Repo: https://github.com/servo/servo
Source-Revision: 8af9ce07f8ec9dddc926c1f76ade9e84427034db

UltraBlame original commit: de3f2703b11e0d467bf92c052904cb1cfd484a9c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…y-cleanup); r=Ms2ger

This code did not use derived traits previously because their methods were not inlined, but this was fixed in rust-lang/rust#10557. r? pcwalton

Source-Repo: https://github.com/servo/servo
Source-Revision: 8af9ce07f8ec9dddc926c1f76ade9e84427034db

UltraBlame original commit: de3f2703b11e0d467bf92c052904cb1cfd484a9c
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

Successfully merging this pull request may close these issues.

3 participants