Skip to content

Commit 418c49a

Browse files
committed
chore: call shrink_to_fit afte parsing source maps
1 parent 4fb2951 commit 418c49a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

crates/artifacts/solc/src/sourcemap.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,20 +556,25 @@ enum State {
556556

557557
impl State {
558558
fn advance(&mut self, pos: usize) -> Result<(), SyntaxError> {
559-
match self {
560-
Self::Offset => *self = Self::Length,
561-
Self::Length => *self = Self::Index,
562-
Self::Index => *self = Self::Jmp,
563-
Self::Jmp => *self = Self::Modifier,
559+
*self = match self {
560+
Self::Offset => Self::Length,
561+
Self::Length => Self::Index,
562+
Self::Index => Self::Jmp,
563+
Self::Jmp => Self::Modifier,
564564
Self::Modifier => return Err(SyntaxError::new(pos, "unexpected colon")),
565-
}
565+
};
566566
Ok(())
567567
}
568568
}
569569

570-
/// Parses a source map
570+
/// Parses a source map.
571571
pub fn parse(input: &str) -> Result<SourceMap, SyntaxError> {
572-
Parser::new(input).collect()
572+
let mut source_map = Vec::new();
573+
for item in Parser::new(input) {
574+
source_map.push(item?);
575+
}
576+
source_map.shrink_to_fit();
577+
Ok(source_map)
573578
}
574579

575580
#[cfg(test)]

0 commit comments

Comments
 (0)