Skip to content

Remove unsafe code from compute_vec_l2sq #936

Description

@arrayka

compute_vec_l2sq uses unsafe to build a slice from a raw pointer, but the caller already has a &[f32] and compute_vecs_l2sq checks data.len() == num_points * dim. This can be written with safe slicing (&data[start..start+dim]) to avoid unnecessary unsafe and reduce the chance of UB if this function is reused without the length precondition.

    let slice = &data[start..start + dim];

Originally posted by @Copilot in #933 (comment)

Activity

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions