Skip to content

Commit

Permalink
docs(span): update docs about ContentEq Vec comparison speed (#5478)
Browse files Browse the repository at this point in the history
Update the docs for `impl ContentEq for Vec` to state in what circumstances `PartialEq` is faster. See #5427 (comment).
  • Loading branch information
overlookmotel committed Sep 5, 2024
1 parent 94a6ac6 commit 3f204a9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/oxc_span/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ impl<'a, T: ContentEq> ContentEq for oxc_allocator::Box<'a, T> {

/// Blanket implementation for [oxc_allocator::Vec] types
///
/// # WARNING
///
/// This implementation is slow compared to `[PartialEq]`, Consider comparing the 2 vectors using
/// that when one is implemented. This implementation takes triple the time the `PartialEq` would take.
/// # Warning
/// This implementation is slow compared to [PartialEq] for native types which are [Copy] (e.g. `u32`).
/// Prefer comparing the 2 vectors using `==` if they contain such native types (e.g. `Vec<u32>`).
/// <https://godbolt.org/z/54on5sMWc>
impl<'a, T: ContentEq> ContentEq for oxc_allocator::Vec<'a, T> {
#[inline]
fn content_eq(&self, other: &Self) -> bool {
Expand Down

0 comments on commit 3f204a9

Please sign in to comment.