From 3f204a9af558648321fe3ede1ab4e0c1934854bd Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:34:17 +0000 Subject: [PATCH] docs(span): update docs about `ContentEq` `Vec` comparison speed (#5478) Update the docs for `impl ContentEq for Vec` to state in what circumstances `PartialEq` is faster. See https://github.com/oxc-project/oxc/pull/5427#discussion_r1744290058. --- crates/oxc_span/src/cmp.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/oxc_span/src/cmp.rs b/crates/oxc_span/src/cmp.rs index acf08893e..0a1eb3555 100644 --- a/crates/oxc_span/src/cmp.rs +++ b/crates/oxc_span/src/cmp.rs @@ -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`). +/// impl<'a, T: ContentEq> ContentEq for oxc_allocator::Vec<'a, T> { #[inline] fn content_eq(&self, other: &Self) -> bool {