Skip to content

Commit

Permalink
refactor(span): remove unused ContentHash::content_hash_slice (#6609)
Browse files Browse the repository at this point in the history
I've replaced it with impls on `Vec<'a, T>`. I'm hoping this removes some bloat in final binaries.
  • Loading branch information
DonIsaac committed Oct 15, 2024
1 parent a00b437 commit 3faee66
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions crates/oxc_span/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
}
}

Expand Down

0 comments on commit 3faee66

Please sign in to comment.