From 07e3b2708e6c1b15b004931dc3465c74c38bf62d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 27 Jan 2025 15:59:03 +0100 Subject: [PATCH 1/2] chore: call shrink_to_fit afte parsing source maps --- crates/artifacts/solc/src/sourcemap.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/artifacts/solc/src/sourcemap.rs b/crates/artifacts/solc/src/sourcemap.rs index aab1e5f85..39fd60bfd 100644 --- a/crates/artifacts/solc/src/sourcemap.rs +++ b/crates/artifacts/solc/src/sourcemap.rs @@ -556,20 +556,23 @@ enum State { impl State { fn advance(&mut self, pos: usize) -> Result<(), SyntaxError> { - match self { - Self::Offset => *self = Self::Length, - Self::Length => *self = Self::Index, - Self::Index => *self = Self::Jmp, - Self::Jmp => *self = Self::Modifier, + *self = match self { + Self::Offset => Self::Length, + Self::Length => Self::Index, + Self::Index => Self::Jmp, + Self::Jmp => Self::Modifier, Self::Modifier => return Err(SyntaxError::new(pos, "unexpected colon")), - } + }; Ok(()) } } -/// Parses a source map +/// Parses a source map. pub fn parse(input: &str) -> Result { - Parser::new(input).collect() + Parser::new(input).collect::>().map(|mut v| { + v.shrink_to_fit(); + v + }) } #[cfg(test)] From c4c4f817e7586537011e22980a4798c237841640 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 27 Jan 2025 17:32:17 +0100 Subject: [PATCH 2/2] chore: clippy --- crates/compilers/src/compilers/solc/compiler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compilers/src/compilers/solc/compiler.rs b/crates/compilers/src/compilers/solc/compiler.rs index e99a09e85..1840c3960 100644 --- a/crates/compilers/src/compilers/solc/compiler.rs +++ b/crates/compilers/src/compilers/solc/compiler.rs @@ -615,7 +615,7 @@ fn version_from_output(output: Output) -> Result { let version = stdout .lines() .filter(|l| !l.trim().is_empty()) - .last() + .next_back() .ok_or_else(|| SolcError::msg("Version not found in Solc output"))?; // NOTE: semver doesn't like `+` in g++ in build metadata which is invalid semver Ok(Version::from_str(&version.trim_start_matches("Version: ").replace(".g++", ".gcc"))?)