Skip to content

Commit

Permalink
Change Lit::short_name to Lit::literal_name.
Browse files Browse the repository at this point in the history
This avoids a moderately hot allocation in `parse_lit_token`.
  • Loading branch information
nnethercote committed Nov 12, 2018
1 parent 5a2ca1a commit c686299
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Expand Up @@ -1956,7 +1956,7 @@ impl<'a> Parser<'a> {

if suffix_illegal {
let sp = self.span;
self.expect_no_suffix(sp, &format!("{} literal", lit.short_name()), suf)
self.expect_no_suffix(sp, lit.literal_name(), suf)
}

result.unwrap()
Expand Down
14 changes: 7 additions & 7 deletions src/libsyntax/parse/token.rs
Expand Up @@ -79,14 +79,14 @@ pub enum Lit {
}

impl Lit {
crate fn short_name(&self) -> &'static str {
crate fn literal_name(&self) -> &'static str {
match *self {
Byte(_) => "byte",
Char(_) => "char",
Integer(_) => "integer",
Float(_) => "float",
Str_(_) | StrRaw(..) => "string",
ByteStr(_) | ByteStrRaw(..) => "byte string"
Byte(_) => "byte literal",
Char(_) => "char literal",
Integer(_) => "integer literal",
Float(_) => "float literal",
Str_(_) | StrRaw(..) => "string literal",
ByteStr(_) | ByteStrRaw(..) => "byte string literal"
}
}

Expand Down

0 comments on commit c686299

Please sign in to comment.