Skip to content

allocUnsafe is useless since 24 #60423

@ChALkeR

Description

@ChALkeR

See #60399 (comment)

What happed to allocUnsafe - does that work at all in 24+?

Since 24.0.0, there is no observable perf difference between alloc and allocUnsafe on large arrays, and allocUnsafe always appears to be zero-filled

In that case places relying on allocUnsafe and then fill would be ~2x faster (or more) if they just used alloc instead of allocUnsafe in the first place

E.g. Buffer.concat([Buffer.alloc(0)], 1e6) is ~10x faster with .alloc instead of .allocUnsafe + .fill, and there appears to be no regression from that change on other Buffer.concat usage

allocUnsafe should be either fixed to be faster than alloc or should be replaced with alloc everywhere (that will simplify things) and deprecated whatsoever

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions