Skip to content

Remove unsafe code from compute_vec_l2sq #936

@arrayka

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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions