From 024df5c8a68928670f10cef45ca3064424016674 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Tue, 20 May 2014 10:37:08 -0700 Subject: [PATCH] syntax: shuffle some allocation out of binop_to_str --- src/libsyntax/parse/token.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 34f508e42a1..8263c7c6852 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -136,18 +136,18 @@ impl fmt::Show for Nonterminal { } } -pub fn binop_to_str(o: BinOp) -> String { +pub fn binop_to_str(o: BinOp) -> &'static str { match o { - PLUS => "+".to_string(), - MINUS => "-".to_string(), - STAR => "*".to_string(), - SLASH => "/".to_string(), - PERCENT => "%".to_string(), - CARET => "^".to_string(), - AND => "&".to_string(), - OR => "|".to_string(), - SHL => "<<".to_string(), - SHR => ">>".to_string() + PLUS => "+", + MINUS => "-", + STAR => "*", + SLASH => "/", + PERCENT => "%", + CARET => "^", + AND => "&", + OR => "|", + SHL => "<<", + SHR => ">>" } } @@ -164,9 +164,9 @@ pub fn to_str(t: &Token) -> String { TILDE => "~".to_string(), OROR => "||".to_string(), ANDAND => "&&".to_string(), - BINOP(op) => binop_to_str(op), + BINOP(op) => binop_to_str(op).to_string(), BINOPEQ(op) => { - let mut s = binop_to_str(op); + let mut s = binop_to_str(op).to_strbuf(); s.push_str("="); s }