diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-11-19 11:13:34 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-11-19 11:18:34 +1100 |
| commit | df0f50381c630c56adcd7ca0023b8daaa3ad2776 (patch) | |
| tree | c52ee43cf8f6a4eb13a76e6d217f1f95d7197d60 /src/libsyntax/ext/deriving/cmp | |
| parent | 3d569df41de221ce5b0ffd385caaa9fd6d5fb2ff (diff) | |
| download | rust-df0f50381c630c56adcd7ca0023b8daaa3ad2776.tar.gz rust-df0f50381c630c56adcd7ca0023b8daaa3ad2776.zip | |
Mark some derived methods as #[inline].
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.)
Diffstat (limited to 'src/libsyntax/ext/deriving/cmp')
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/eq.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/ord.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totaleq.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totalord.rs | 1 |
4 files changed, 4 insertions, 0 deletions
diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 468e3e5e7f2..eb07d2d209c 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -37,6 +37,7 @@ pub fn expand_deriving_eq(cx: @ExtCtxt, explicit_self: borrowed_explicit_self(), args: ~[borrowed_self()], ret_ty: Literal(Path::new(~["bool"])), + inline: true, const_nonmatching: true, combine_substructure: $f } diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index 33f45d45bdb..95d617af0c7 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -27,6 +27,7 @@ pub fn expand_deriving_ord(cx: @ExtCtxt, explicit_self: borrowed_explicit_self(), args: ~[borrowed_self()], ret_ty: Literal(Path::new(~["bool"])), + inline: true, const_nonmatching: false, combine_substructure: |cx, span, substr| cs_op($op, $equal, cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index c6123451071..51965e1b582 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -34,6 +34,7 @@ pub fn expand_deriving_totaleq(cx: @ExtCtxt, explicit_self: borrowed_explicit_self(), args: ~[borrowed_self()], ret_ty: Literal(Path::new(~["bool"])), + inline: true, const_nonmatching: true, combine_substructure: cs_equals } diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index 34c6d1104da..217acd98c68 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -31,6 +31,7 @@ pub fn expand_deriving_totalord(cx: @ExtCtxt, explicit_self: borrowed_explicit_self(), args: ~[borrowed_self()], ret_ty: Literal(Path::new(~["std", "cmp", "Ordering"])), + inline: true, const_nonmatching: false, combine_substructure: cs_cmp } |
