Skip to content

Commit 07e3b27

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

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

crates/artifacts/solc/src/sourcemap.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,20 +556,23 @@ 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+
Parser::new(input).collect::<Result<SourceMap, SyntaxError>>().map(|mut v| {
573+
v.shrink_to_fit();
574+
v
575+
})
573576
}
574577

575578
#[cfg(test)]

0 commit comments

Comments
 (0)