Skip to content

Remove array ref to reduce code size#151

Merged
AdamGS merged 1 commit into
developfrom
adamg/remove-array-ref-for-code-size
Jun 12, 2026
Merged

Remove array ref to reduce code size#151
AdamGS merged 1 commit into
developfrom
adamg/remove-array-ref-for-code-size

Conversation

@AdamGS

@AdamGS AdamGS commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Build times are basically the same, but the rlib is 3.9MB instead of 5.4MB

@robert3005

Copy link
Copy Markdown
Member

curious why these don't inline to the same thing? Anyway 👍

@codspeed-hq

codspeed-hq Bot commented Jun 12, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 158 untouched benchmarks
⏩ 123 skipped benchmarks1


Comparing adamg/remove-array-ref-for-code-size (397d1ff) with develop (5a7cd72)

Open in CodSpeed

Footnotes

  1. 123 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.

@AdamGS

AdamGS commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

array_ref! is:

macro_rules! array_ref {
    ($arr:expr, $offset:expr, $len:expr) => {{
        {
            #[inline]
            const unsafe fn as_array<T>(slice: &[T]) -> &[T; $len] {
                &*(slice.as_ptr() as *const [_; $len])
            }
            let offset = $offset;
            let slice = &$arr[offset..offset + $len];
            #[allow(unused_unsafe)]
            unsafe {
                as_array(slice)
            }
        }
    }};
}

and the &$arr[offset..offset + $len]; hides a panic IMO, which makes it more code

Signed-off-by: Adam Gutglick <adam@spiraldb.com>
@AdamGS AdamGS force-pushed the adamg/remove-array-ref-for-code-size branch from 0932cdf to 397d1ff Compare June 12, 2026 14:50
@AdamGS AdamGS marked this pull request as ready for review June 12, 2026 14:53
@AdamGS AdamGS merged commit 0e62e40 into develop Jun 12, 2026
5 checks passed
@AdamGS AdamGS deleted the adamg/remove-array-ref-for-code-size branch June 12, 2026 15:11
@github-actions github-actions Bot mentioned this pull request Jun 4, 2026
AdamGS pushed a commit that referenced this pull request Jun 12, 2026
## 🤖 New release

* `fastlanes`: 0.5.1 -> 0.5.2 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>


##
[0.5.2](v0.5.1...v0.5.2) -
2026-06-12

### Other

- Remove array ref to reduce code size
([#151](#151))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants