about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorCorey Richardson <corey@octayn.net>2014-05-20 10:37:08 -0700
committerCorey Richardson <corey@octayn.net>2014-06-03 21:00:55 -0700
commit024df5c8a68928670f10cef45ca3064424016674 (patch)
tree067602c7d03d819fb996b0aa7f9a5169419e1ae5 /src/libsyntax
parent507c1a0fc99b3a090beefd8a3887f21db98ecb09 (diff)
downloadrust-024df5c8a68928670f10cef45ca3064424016674.tar.gz
rust-024df5c8a68928670f10cef45ca3064424016674.zip
syntax: shuffle some allocation out of binop_to_str
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/parse/token.rs26
1 files 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
       }