mirror of
https://github.com/danbulant/oxc
synced 2026-05-23 06:08:47 +00:00
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:
parent
a00b43717d
commit
3faee66400
1 changed files with 11 additions and 11 deletions
|
|
@ -10,16 +10,6 @@ use std::{
|
||||||
/// As an example, In AST types we ignore fields such as [crate::Span].
|
/// As an example, In AST types we ignore fields such as [crate::Span].
|
||||||
pub trait ContentHash {
|
pub trait ContentHash {
|
||||||
fn content_hash<H: Hasher>(&self, state: &mut H);
|
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.
|
/// 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> {
|
impl<'a, T: ContentHash> ContentHash for oxc_allocator::Vec<'a, T> {
|
||||||
fn content_hash<H: Hasher>(&self, state: &mut H) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue