Change Lit::short_name to Lit::literal_name.
This avoids a moderately hot allocation in `parse_lit_token`.
This commit is contained in:
@@ -1956,7 +1956,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
if suffix_illegal {
|
if suffix_illegal {
|
||||||
let sp = self.span;
|
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()
|
result.unwrap()
|
||||||
|
|||||||
@@ -79,14 +79,14 @@ pub enum Lit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Lit {
|
impl Lit {
|
||||||
crate fn short_name(&self) -> &'static str {
|
crate fn literal_name(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
Byte(_) => "byte",
|
Byte(_) => "byte literal",
|
||||||
Char(_) => "char",
|
Char(_) => "char literal",
|
||||||
Integer(_) => "integer",
|
Integer(_) => "integer literal",
|
||||||
Float(_) => "float",
|
Float(_) => "float literal",
|
||||||
Str_(_) | StrRaw(..) => "string",
|
Str_(_) | StrRaw(..) => "string literal",
|
||||||
ByteStr(_) | ByteStrRaw(..) => "byte string"
|
ByteStr(_) | ByteStrRaw(..) => "byte string literal"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user