-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Adjust ok_or and map_or to _else for lazy computation #14764
Conversation
⏱️ 2h total CI duration on this PR
🚨 1 job on the last run was significantly faster/slower than expected
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14764 +/- ##
=========================================
- Coverage 60.1% 60.0% -0.1%
=========================================
Files 856 856
Lines 210845 210892 +47
=========================================
- Hits 126742 126737 -5
- Misses 84103 84155 +52 ☔ View full report in Codecov by Sentry. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
lgtm
A pass for |
there is also straight up or( that I didn't look for yet |
let mut prev_modified_keys = last_input_output | ||
.modified_keys(idx_to_execute) | ||
.map_or(HashMap::new(), |keys| keys.collect()); | ||
let mut prev_modified_keys = match last_input_output.modified_keys(idx_to_execute) { |
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.
why not just map_or_else?
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.
issues with type deduction somehow
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.
if there's error you just need to annotate the types like keys.collect::<HashMap<,>>() but I also don't see errors when trying it
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 tried annotating and kept seeing weird errors, will try again
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.
worked out, must have been on some weird local state
let output_prefix = options.move_sources.first().map_or("bytecode", |s| { | ||
Path::new(s).file_name().unwrap().to_str().unwrap() | ||
}); | ||
let output_prefix = options.move_sources.first().map_or_else( |
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.
const literals are cheaper than functions?
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.
true, missed this one, usually the linter would complain in this case. will revert.
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.
you have this in multiple places as far as I can see
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.
will do a pass. For sure left a bunch unchanged and got linter errors and reverted on some. string literal def can stay in or(
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 I got all of them
let mut prev_modified_keys = last_input_output | ||
.modified_keys(idx_to_execute) | ||
.map_or(HashMap::new(), |keys| keys.collect()); | ||
let mut prev_modified_keys = match last_input_output.modified_keys(idx_to_execute) { |
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.
if there's error you just need to annotate the types like keys.collect::<HashMap<,>>() but I also don't see errors when trying it
287eb78
to
54c63b7
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
Audit and adjust the uses, e.g. where there is error preparation or string formatting on the unhappy path, to make sure it doesn't execute eagerly on the happy path.
How Has This Been Tested?
passes existing
Type of Change
Which Components or Systems Does This Change Impact?