-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[sui-pkg-alt] move-analyzer fixes #24493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sui-pkg-alt
Are you sure you want to change the base?
[sui-pkg-alt] move-analyzer fixes #24493
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| // TODO: we need to rework on loading the root pkg only once. | ||
| let dependencies = root_pkg.packages(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved it up a bit
| let clean = strip_comments(contents); | ||
| let mut set = HashSet::new(); | ||
|
|
||
| // This matches `module a::b {}`, and `module a::b;` cases. | ||
| // In both cases, the match is the 2nd group (so `match.get(1)`) | ||
| let regex = Regex::new(MODULE_REGEX).unwrap(); | ||
|
|
||
| for cap in regex.captures_iter(&clean) { | ||
| set.insert(cap[1].to_string()); | ||
| } | ||
|
|
||
| Ok(set | ||
| .into_iter() | ||
| .filter(|name| !is_address_like(name.as_str())) | ||
| Ok(MODULE_REGEX_COMPILED | ||
| .captures_iter(&clean) | ||
| .filter_map(|cap| { | ||
| let name = &cap[1]; | ||
| (!is_address_like(name)).then(|| name.to_string()) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be slightly more optimized, particularly that we're reusing the REGEX rather than creating a new one every time.
…x rather than creating a new one every time
b9a3348 to
207730e
Compare
Description
This PR brings a few fixes to move-analyzer and a small optimization to reuse a regex rather than creating a new one every time.
Test plan
Existing tests.
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.