diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-17 00:06:23 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-17 00:06:23 +0100 |
commit | 1afdc579297f68dadbe8ee580040ec6ca95cc58b (patch) | |
tree | 478b8f648fed106b71ea455410be08707dfac4f2 /crates/ra_parser/src | |
parent | 8944a9b35a71c58d2ed903fb2b29dfeeb10d29cd (diff) | |
parent | 1e9172d70cf714dc006c1cbc4a029ae6e848d35b (diff) |
Merge #4489
4489: Memory allocation optimization r=matklad a=simonvandel
I did some profiling using DHAT, and this was what I could easily optimize without much knowledge of the codebase.
This speeds up analysis-stats on rust-analyser by ~4% on my local machine.
**Benchmark**
➜ rust-analyzer-base git:(master) hyperfine --min-runs=2 '/home/simon/Documents/rust-analyzer/target/release/rust-analyzer analysis-stats .' '/home/simon/Documents/rust-analyzer-base/target/release/rust-analyzer analysis-stats .'
Benchmark #1: /home/simon/Documents/rust-analyzer/target/release/rust-analyzer analysis-stats .
Time (mean ± σ): 49.621 s ± 0.317 s [User: 48.725 s, System: 0.792 s]
Range (min … max): 49.397 s … 49.846 s 2 runs
Benchmark #2: /home/simon/Documents/rust-analyzer-base/target/release/rust-analyzer analysis-stats .
Time (mean ± σ): 51.764 s ± 0.045 s [User: 50.882 s, System: 0.756 s]
Range (min … max): 51.733 s … 51.796 s 2 runs
Summary
'/home/simon/Documents/rust-analyzer/target/release/rust-analyzer analysis-stats .' ran
1.04 ± 0.01 times faster than '/home/simon/Documents/rust-analyzer-base/target/release/rust-analyzer analysis-stats .'
Co-authored-by: Simon Vandel Sillesen <[email protected]>
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r-- | crates/ra_parser/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/parser.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_parser/src/lib.rs b/crates/ra_parser/src/lib.rs index e08ad4dae..eeb8ad66b 100644 --- a/crates/ra_parser/src/lib.rs +++ b/crates/ra_parser/src/lib.rs | |||
@@ -25,7 +25,7 @@ pub(crate) use token_set::TokenSet; | |||
25 | pub use syntax_kind::SyntaxKind; | 25 | pub use syntax_kind::SyntaxKind; |
26 | 26 | ||
27 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 27 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
28 | pub struct ParseError(pub String); | 28 | pub struct ParseError(pub Box<String>); |
29 | 29 | ||
30 | /// `TokenSource` abstracts the source of the tokens parser operates on. | 30 | /// `TokenSource` abstracts the source of the tokens parser operates on. |
31 | /// | 31 | /// |
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index faa63d53f..4f59b0a23 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs | |||
@@ -192,7 +192,7 @@ impl<'t> Parser<'t> { | |||
192 | /// structured errors with spans and notes, like rustc | 192 | /// structured errors with spans and notes, like rustc |
193 | /// does. | 193 | /// does. |
194 | pub(crate) fn error<T: Into<String>>(&mut self, message: T) { | 194 | 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())); |
196 | self.push_event(Event::Error { msg }) | 196 | self.push_event(Event::Error { msg }) |
197 | } | 197 | } |
198 | 198 | ||