Allow inlining of `array::map()`
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- rust
- Domain
- performance
Research direction
Locate the standard-library definitions of array::map() and array::try_map(), then inspect how their current implementations handle inlining. Add the requested inlining attributes to both methods and verify that the relevant standard-library checks pass and the methods can inline in performance-sensitive use cases.
Written by the indexing model from the issue text.
Description
Right now array::map() and array::try_map() do not allow inlining, which makes it not possible to use these convenience methods in performance-sensitive cases and requires writing much more verbose loops.
For example, this doesn't inline:
let lut = rs1.to_le_bytes();
let result = rs2.to_le_bytes().map(|idx| {
*lut.get(usize::from(idx)).unwrap_or(&0)
});
But this does:
let lut = rs1.to_le_bytes();
let mut result = [0; _];
for (&idx, r) in rs2.to_le_bytes().iter().zip(&mut result) {
*r = *lut.get(usize::from(idx)).unwrap_or(&0);
}
But the first option is much more natural.
Adding #[inline] on both array::map() and array::try_map() would really help here.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 510
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/rust
-
needs-triage O-unix relnotes relnotes-tracking-issue T-libs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
A-CI A-spurious C-bug O-fuchsia T-infra
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
A-run-make needs-triage O-hermit O-linux O-netbsd O-redox O-SGX O-solid O-unix O-wasi O-wasm O-windows relnotes relnotes-tracking-issue T-compiler T-rustdoc
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
A-attributes needs-triage relnotes relnotes-tracking-issue T-compiler
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
needs-triage O-SGX relnotes relnotes-tracking-issue T-libs
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·