refactor(span): remove unused ContentHash::content_hash_slice (#6609)

I've replaced it with impls on `Vec<'a, T>`. I'm hoping this removes some bloat in final binaries.
This commit is contained in:
DonIsaac 2024-10-15 22:50:42 +00:00
parent a00b43717d
commit 3faee66400

View file

@ -10,16 +10,6 @@ use std::{
/// As an example, In AST types we ignore fields such as [crate::Span].
pub trait ContentHash {
fn content_hash<H: Hasher>(&self, state: &mut H);
/// The default implementation is usually sufficient.
fn content_hash_slice<H: Hasher>(data: &[Self], state: &mut H)
where
Self: Sized,
{
for piece in data {
piece.content_hash(state);
}
}
}
/// Short-Circuting implementation for [Discriminant] since it is used to hash enums.
@ -46,7 +36,17 @@ impl<'a, T: ContentHash> ContentHash for oxc_allocator::Box<'a, T> {
impl<'a, T: ContentHash> ContentHash for oxc_allocator::Vec<'a, T> {
fn content_hash<H: Hasher>(&self, state: &mut H) {
ContentHash::content_hash_slice(self.as_slice(), state);
for piece in self {
piece.content_hash(state);
}
}
}
impl<T: ContentHash> ContentHash for [T] {
fn content_hash<H: Hasher>(&self, state: &mut H) {
for piece in self {
piece.content_hash(state);
}
}
}