Skip to content

Commit

Permalink
perf: fast path with src.contains
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Mar 18, 2024
1 parent 5fd45a1 commit a3b20da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ debug = 1
# Solc and artifacts
foundry-compilers.opt-level = 3
solang-parser.opt-level = 3
lalrpop-util.opt-level = 3
serde_json.opt-level = 3

# EVM
Expand Down
5 changes: 5 additions & 0 deletions crates/config/src/inline/natspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ impl SolangParser {
contract_id: &str,
contract_name: &str,
) {
// Fast path to avoid parsing the file.
if !src.contains(INLINE_CONFIG_PREFIX) {
return;
}

let Ok((pt, comments)) = solang_parser::parse(src, 0) else { return };
let mut prev_end = 0;
for item in &pt.0 {
Expand Down

0 comments on commit a3b20da

Please sign in to comment.