From aeb6b74725b3eecda3eecec20b4f37d815dc929c Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Tue, 10 Dec 2024 15:52:22 +0100 Subject: [PATCH] Make sure we use an FxHashBuilder on the Value --- Cargo.lock | 4 ++-- crates/milli/src/prompt/document.rs | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34bea88da..9476506ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -708,9 +708,9 @@ dependencies = [ [[package]] name = "bumparaw-collections" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833a74d1cb25094593307c17044e4140828b553d1d653bc3ec9928aa88a6d88a" +checksum = "4ce682bdc86c2e25ef5cd95881d9d6a1902214eddf74cf9ffea88fe1464377e8" dependencies = [ "allocator-api2", "bitpacking", diff --git a/crates/milli/src/prompt/document.rs b/crates/milli/src/prompt/document.rs index 5232b6788..ae0a506ac 100644 --- a/crates/milli/src/prompt/document.rs +++ b/crates/milli/src/prompt/document.rs @@ -9,6 +9,7 @@ use liquid::model::{ Value as LiquidValue, }; use liquid::{ObjectView, ValueView}; +use rustc_hash::FxBuildHasher; use serde_json::value::RawValue; use crate::update::del_add::{DelAdd, KvReaderDelAdd}; @@ -195,7 +196,7 @@ impl<'doc, D: DocumentTrait<'doc> + Debug> ObjectView for ParseableDocument<'doc } impl<'doc, D: DocumentTrait<'doc> + Debug> ValueView for ParseableDocument<'doc, D> { - fn as_debug(&self) -> &dyn fmt::Debug { + fn as_debug(&self) -> &dyn Debug { self } fn render(&self) -> liquid::model::DisplayCow<'_> { @@ -243,14 +244,13 @@ impl<'doc, D: DocumentTrait<'doc> + Debug> ValueView for ParseableDocument<'doc, } } -#[derive(Debug)] struct ParseableValue<'doc> { - value: Value<'doc>, + value: Value<'doc, FxBuildHasher>, } impl<'doc> ParseableValue<'doc> { pub fn new(value: &'doc RawValue, doc_alloc: &'doc Bump) -> Self { - let value = Value::from_raw_value(value, doc_alloc).unwrap(); + let value = Value::from_raw_value_and_hasher(value, FxBuildHasher, doc_alloc).unwrap(); Self { value } } @@ -260,19 +260,19 @@ impl<'doc> ParseableValue<'doc> { } // transparent newtype for implementing ValueView -#[repr(transparent)] #[derive(Debug)] -struct ParseableMap<'doc>(RawMap<'doc>); +#[repr(transparent)] +struct ParseableMap<'doc>(RawMap<'doc, FxBuildHasher>); // transparent newtype for implementing ValueView -#[repr(transparent)] #[derive(Debug)] +#[repr(transparent)] struct ParseableArray<'doc>(RawVec<'doc>); impl<'doc> ParseableMap<'doc> { - pub fn as_parseable<'a>(map: &'a RawMap<'doc>) -> &'a ParseableMap<'doc> { + pub fn as_parseable<'a>(map: &'a RawMap<'doc, FxBuildHasher>) -> &'a ParseableMap<'doc> { // SAFETY: repr(transparent) - unsafe { &*(map as *const RawMap as *const Self) } + unsafe { &*(map as *const RawMap as *const Self) } } } @@ -612,6 +612,12 @@ impl<'doc> ValueView for ParseableValue<'doc> { } } +impl Debug for ParseableValue<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ParseableValue").field("value", &self.value).finish() + } +} + struct ArraySource<'s, 'doc> { s: &'s RawVec<'doc>, }