Skip to content

perf(array): add dense array fast-path for Array.prototype.unshift#5329

Open
Exar04 wants to merge 1 commit intoboa-dev:mainfrom
Exar04:optimize-array-unshift
Open

perf(array): add dense array fast-path for Array.prototype.unshift#5329
Exar04 wants to merge 1 commit intoboa-dev:mainfrom
Exar04:optimize-array-unshift

Conversation

@Exar04
Copy link
Copy Markdown

@Exar04 Exar04 commented Apr 13, 2026

ref: #3407

@Exar04 Exar04 requested a review from a team as a code owner April 13, 2026 17:28
@github-actions github-actions bot added Waiting On Review Waiting on reviews from the maintainers C-Builtins PRs and Issues related to builtins/intrinsics and removed Waiting On Review Waiting on reviews from the maintainers labels Apr 13, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Apr 13, 2026
Signed-off-by: Exar04 <yashdhadwe@gmail.com>
@Exar04 Exar04 force-pushed the optimize-array-unshift branch from c217680 to a4a2a88 Compare April 13, 2026 17:32
@github-actions github-actions bot added the Waiting On Review Waiting on reviews from the maintainers label Apr 13, 2026
let props = &mut o_borrow.properties_mut().indexed_properties;

let fast_path = match props {
IndexedProperties::DenseI32(dense) if dense.len() as u64 == len => {
Copy link
Copy Markdown
Author

@Exar04 Exar04 Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we are iterating over values that will be added to array and converting it to type i32.
But what if we encounter string or f64? according to blog shared in issue, the type of array should get converted to lower type i.e DenseI32 -> DenseF64.
But we aren't doing that here (even before I added this code), is it getting handled somewhere else?

also if I am right about above, instead of getting out of match when encountering f64 instead of i32 it would be more performant to try again match.

something like this ->

fn main() {
    let mut b = 1;
    let a = loop {
        match b {
        1 => {
            b = 2;
            if b == 2{
                continue
            }
            break "one"
        },
        2 => break "two",
        _ => break "other",
    }
    };
    println!("{}", a);
}

but idk... its just a thought

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Builtins PRs and Issues related to builtins/intrinsics Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant