We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 85a8be1 commit 2225547Copy full SHA for 2225547
crates/interface/src/source_map/analyze.rs
@@ -7,7 +7,11 @@ use crate::pos::RelativeBytePos;
7
/// This function will use an SSE2 enhanced implementation if hardware support
8
/// is detected at runtime.
9
pub(crate) fn analyze_source_file(src: &str) -> (Vec<RelativeBytePos>, Vec<MultiByteChar>) {
10
- let mut lines = vec![RelativeBytePos::from_u32(0)];
+ // In most cases this will re-allocate 0 or 1 times.
11
+ let lines_upper_bound = 1 + src.len() / 32;
12
+ let mut lines = Vec::with_capacity(lines_upper_bound);
13
+ lines.push(RelativeBytePos::from_u32(0));
14
+
15
let mut multi_byte_chars = vec![];
16
17
// Calls the right implementation, depending on hardware support available.
0 commit comments