diff options
| author | Björn Steinbrink <bsteinbr@gmail.com> | 2013-05-02 10:16:07 +0200 |
|---|---|---|
| committer | Björn Steinbrink <bsteinbr@gmail.com> | 2013-05-09 14:40:19 +0200 |
| commit | 1393c3a3f438c896083405dca501c8cf05767c65 (patch) | |
| tree | 792b87a17ae08527e0bffe39cfda8730165f212a /src/libsyntax/ext/deriving/cmp | |
| parent | 936c07dcf0137b7ef456e82b9e70c3a2743dbe16 (diff) | |
Use a specialized string interner to reduce the need for owned strings
&str can be turned into @~str on demand, using to_owned(), so for strings, we can create a specialized interner that accepts &str for intern() and find() but stores and returns @~str.
Diffstat (limited to 'src/libsyntax/ext/deriving/cmp')
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/ord.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totalord.rs | 16 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index 5998fc7145d..a9234c858f4 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -58,9 +58,9 @@ fn cs_ord(less: bool, equal: bool, cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr { let binop = if less { - cx.ident_of(~"lt") + cx.ident_of("lt") } else { - cx.ident_of(~"gt") + cx.ident_of("gt") }; let false_blk_expr = build::mk_block(cx, span, ~[], ~[], @@ -101,7 +101,7 @@ fn cs_ord(less: bool, equal: bool, } let cmp = build::mk_method_call(cx, span, - self_f, cx.ident_of(~"eq"), other_fs.to_owned()); + self_f, cx.ident_of("eq"), other_fs.to_owned()); let subexpr = build::mk_simple_block(cx, span, subexpr); let elseif = expr_if(cmp, subexpr, Some(false_blk_expr)); let elseif = build::mk_expr(cx, span, elseif); diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index ac873c5bd12..7d560a197d0 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -43,21 +43,21 @@ pub fn expand_deriving_totalord(cx: @ext_ctxt, pub fn ordering_const(cx: @ext_ctxt, span: span, cnst: Ordering) -> @expr { let cnst = match cnst { - Less => ~"Less", - Equal => ~"Equal", - Greater => ~"Greater" + Less => "Less", + Equal => "Equal", + Greater => "Greater" }; build::mk_path_global(cx, span, - ~[cx.ident_of(~"core"), - cx.ident_of(~"cmp"), + ~[cx.ident_of("core"), + cx.ident_of("cmp"), cx.ident_of(cnst)]) } pub fn cs_cmp(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr { - let lexical_ord = ~[cx.ident_of(~"core"), - cx.ident_of(~"cmp"), - cx.ident_of(~"lexical_ordering")]; + let lexical_ord = ~[cx.ident_of("core"), + cx.ident_of("cmp"), + cx.ident_of("lexical_ordering")]; cs_same_method_fold( // foldr (possibly) nests the matches in lexical_ordering better |
