Skip to content

Commit ef6d535

Browse files
committed
Shrink ra_parser::Event from 32 bytes to 16 bytes
This boxes the Error variant with the assumption that it is rarely constructed
1 parent ebaa05a commit ef6d535

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

crates/ra_parser/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) use token_set::TokenSet;
2525
pub use syntax_kind::SyntaxKind;
2626

2727
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
28-
pub struct ParseError(pub String);
28+
pub struct ParseError(pub Box<String>);
2929

3030
/// `TokenSource` abstracts the source of the tokens parser operates on.
3131
///

crates/ra_parser/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'t> Parser<'t> {
192192
/// structured errors with spans and notes, like rustc
193193
/// does.
194194
pub(crate) fn error<T: Into<String>>(&mut self, message: T) {
195-
let msg = ParseError(message.into());
195+
let msg = ParseError(Box::new(message.into()));
196196
self.push_event(Event::Error { msg })
197197
}
198198

crates/ra_syntax/src/syntax_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ impl SyntaxTreeBuilder {
7070
}
7171

7272
pub fn error(&mut self, error: ra_parser::ParseError, text_pos: TextSize) {
73-
self.errors.push(SyntaxError::new_at_offset(error.0, text_pos))
73+
self.errors.push(SyntaxError::new_at_offset(*error.0, text_pos))
7474
}
7575
}

0 commit comments

Comments
 (0)