Change the hashcounts in raw Lit variants from usize to u16.

This reduces the size of `Token` from 32 bytes to 24 bytes on 64-bit
platforms.
This commit is contained in:
Nicholas Nethercote
2018-04-12 19:50:53 +10:00
parent d26f9e42df
commit 4d34bfd00a
7 changed files with 19 additions and 14 deletions
+3 -3
View File
@@ -133,12 +133,12 @@ pub fn try_next_token(&mut self) -> Result<TokenAndSpan, ()> {
Ok(ret_val)
}
fn fail_unterminated_raw_string(&self, pos: BytePos, hash_count: usize) {
fn fail_unterminated_raw_string(&self, pos: BytePos, hash_count: u16) {
let mut err = self.struct_span_fatal(pos, pos, "unterminated raw string");
err.span_label(self.mk_sp(pos, pos), "unterminated raw string");
if hash_count > 0 {
err.note(&format!("this raw string should be terminated with `\"{}`",
"#".repeat(hash_count)));
"#".repeat(hash_count as usize)));
}
err.emit();
FatalError.raise();
@@ -1439,7 +1439,7 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
'r' => {
let start_bpos = self.pos;
self.bump();
let mut hash_count = 0;
let mut hash_count: u16 = 0;
while self.ch_is('#') {
self.bump();
hash_count += 1;
+2 -2
View File
@@ -72,9 +72,9 @@ pub enum Lit {
Integer(ast::Name),
Float(ast::Name),
Str_(ast::Name),
StrRaw(ast::Name, usize), /* raw str delimited by n hash symbols */
StrRaw(ast::Name, u16), /* raw str delimited by n hash symbols */
ByteStr(ast::Name),
ByteStrRaw(ast::Name, usize), /* raw byte str delimited by n hash symbols */
ByteStrRaw(ast::Name, u16), /* raw byte str delimited by n hash symbols */
}
impl Lit {