From bc50bb5859a97ba8f7d0fb178af201de7ce29a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20d=27Herbais=20de=20Thun?= Date: Sun, 7 Jul 2024 14:30:07 +0200 Subject: [PATCH] Small touches & cleanup --- src/cache.rs | 4 +++- src/lib.rs | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cache.rs b/src/cache.rs index 006136f..d0a5d28 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -32,6 +32,7 @@ where F: FnOnce(In::Tracked<'c>) -> Out, { // Early bypass if memoization is disabled. + // Hopefully the compiler will optimize this away, if the condition is constant. if !enabled { return memoized_disabled(input, constraint, func); } @@ -79,7 +80,7 @@ where output } -pub fn memoized_disabled<'c, In, Out, F>( +fn memoized_disabled<'c, In, Out, F>( input: In, constraint: &'c In::Constraint, func: F, @@ -96,6 +97,7 @@ where // Add the new constraints to the outer ones. outer.join(constraint); + // Ensure that the last call was a miss during testing. #[cfg(feature = "testing")] LAST_WAS_HIT.with(|cell| cell.set(false)); diff --git a/src/lib.rs b/src/lib.rs index 7a282da..5921b7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -99,9 +99,7 @@ pub use comemo_macros::{memoize, track}; pub mod internal { pub use parking_lot::RwLock; - pub use crate::cache::{ - memoized, memoized_disabled, register_evictor, Cache, CacheData, - }; + pub use crate::cache::{memoized, register_evictor, Cache, CacheData}; pub use crate::constraint::{hash, Call, ImmutableConstraint, MutableConstraint}; pub use crate::input::{assert_hashable_or_trackable, Args, Input}; pub use crate::track::{to_parts_mut_mut, to_parts_mut_ref, to_parts_ref, Surfaces};