simplify many match - #13801
Conversation
|
GNU testsuite comparison: |
| parse_gid_from_str(from_group) | ||
| .map(IfFrom::Group) | ||
| .map_err(|_| { | ||
| USimpleError::new( | ||
| 1, | ||
| translate!("chgrp-error-invalid-user", "from_group" => from_group), | ||
| )); | ||
| } | ||
| } | ||
| ) | ||
| })? |
There was a problem hiding this comment.
I prefer let-else over map_err with an intentional ignore:
| parse_gid_from_str(from_group) | |
| .map(IfFrom::Group) | |
| .map_err(|_| { | |
| USimpleError::new( | |
| 1, | |
| translate!("chgrp-error-invalid-user", "from_group" => from_group), | |
| )); | |
| } | |
| } | |
| ) | |
| })? | |
| let Ok(g) = parse_gid_from_str(from_group) else { | |
| return Err(USimpleError::new( | |
| 1, | |
| translate!("chgrp-error-invalid-user", "from_group" => from_group), | |
| )); | |
| }; | |
| IfFrom::Group(g) |
In this case, the if could also be collapsed into a let-chain.
There was a problem hiding this comment.
thiserror could be used for that too, something like #13620
Merging this PR will degrade performance by 3.39%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | numfmt_to_si_precision[10000] |
90.6 ms | 93.8 ms | -3.39% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing oech3:fmt-ret-err (548f9a2) with main (5d75e5e)
Footnotes
-
46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
Please ping me when it is ready |
ready (CI is passing). |
|
Conflicts with #13620. |
No description provided.