From 2d32ac73b63c81ea2754916feb7758c042f4ed3d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 13 May 2024 19:54:34 +0200 Subject: Replace all `Prehashed` with `LazyHash` (#4127) --- tests/fuzz/src/compile.rs | 14 +++++++------- tests/src/world.rs | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/fuzz/src/compile.rs b/tests/fuzz/src/compile.rs index 2d445bf5..4dbea410 100644 --- a/tests/fuzz/src/compile.rs +++ b/tests/fuzz/src/compile.rs @@ -1,18 +1,18 @@ #![no_main] -use comemo::Prehashed; use libfuzzer_sys::fuzz_target; use typst::diag::{FileError, FileResult}; use typst::eval::Tracer; use typst::foundations::{Bytes, Datetime}; use typst::syntax::{FileId, Source}; use typst::text::{Font, FontBook}; +use typst::utils::LazyHash; use typst::visualize::Color; use typst::{Library, World}; struct FuzzWorld { - library: Prehashed, - book: Prehashed, + library: LazyHash, + book: LazyHash, font: Font, source: Source, } @@ -23,8 +23,8 @@ impl FuzzWorld { let font = Font::new(Bytes::from_static(data), 0).unwrap(); let book = FontBook::from_fonts([&font]); Self { - library: Prehashed::new(Library::default()), - book: Prehashed::new(book), + library: LazyHash::new(Library::default()), + book: LazyHash::new(book), font, source: Source::detached(text), } @@ -32,11 +32,11 @@ impl FuzzWorld { } impl World for FuzzWorld { - fn library(&self) -> &Prehashed { + fn library(&self) -> &LazyHash { &self.library } - fn book(&self) -> &Prehashed { + fn book(&self) -> &LazyHash { &self.book } diff --git a/tests/src/world.rs b/tests/src/world.rs index 86ee8da6..ad925a53 100644 --- a/tests/src/world.rs +++ b/tests/src/world.rs @@ -5,7 +5,6 @@ use std::io::Write; use std::path::{Path, PathBuf}; use std::sync::OnceLock; -use comemo::Prehashed; use once_cell::sync::Lazy; use parking_lot::Mutex; use typst::diag::{bail, FileError, FileResult, StrResult}; @@ -13,6 +12,7 @@ use typst::foundations::{func, Bytes, Datetime, NoneValue, Repr, Smart, Value}; use typst::layout::{Abs, Margin, PageElem}; use typst::syntax::{FileId, Source}; use typst::text::{Font, FontBook, TextElem, TextSize}; +use typst::utils::LazyHash; use typst::visualize::Color; use typst::{Library, World}; @@ -35,11 +35,11 @@ impl TestWorld { } impl World for TestWorld { - fn library(&self) -> &Prehashed { + fn library(&self) -> &LazyHash { &self.base.library } - fn book(&self) -> &Prehashed { + fn book(&self) -> &LazyHash { &self.base.book } @@ -81,8 +81,8 @@ impl TestWorld { /// Shared foundation of all test worlds. struct TestBase { - library: Prehashed, - book: Prehashed, + library: LazyHash, + book: LazyHash, fonts: Vec, slots: Mutex>, } @@ -95,8 +95,8 @@ impl Default for TestBase { .collect(); Self { - library: Prehashed::new(library()), - book: Prehashed::new(FontBook::from_fonts(&fonts)), + library: LazyHash::new(library()), + book: LazyHash::new(FontBook::from_fonts(&fonts)), fonts, slots: Mutex::new(HashMap::new()), } -- cgit v1.2.3