File tree Expand file tree Collapse file tree 1 file changed +7
-26
lines changed
Expand file tree Collapse file tree 1 file changed +7
-26
lines changed Original file line number Diff line number Diff line change 3232 F : FnOnce ( In ) -> Out ,
3333{
3434 // Early bypass if memoization is disabled.
35- // Hopefully the compiler will optimize this away, if the condition is constant.
3635 if !enabled {
37- return memoized_disabled ( input, constraint, func) ;
36+ let output = func ( input) ;
37+
38+ // Ensure that the last call was a miss during testing.
39+ #[ cfg( feature = "testing" ) ]
40+ LAST_WAS_HIT . with ( |cell| cell. set ( false ) ) ;
41+
42+ return output;
3843 }
3944
4045 // Compute the hash of the input's key part.
8085 output
8186}
8287
83- fn memoized_disabled < ' a , In , Out , F > (
84- input : In ,
85- constraint : & ' a In :: Constraint ,
86- func : F ,
87- ) -> Out
88- where
89- In : Input < ' a > ,
90- Out : Clone + ' static ,
91- F : FnOnce ( In ) -> Out ,
92- {
93- // Execute the function with the new constraints hooked in.
94- let ( input, outer) = input. retrack ( constraint) ;
95- let output = func ( input) ;
96-
97- // Add the new constraints to the outer ones.
98- outer. join ( constraint) ;
99-
100- // Ensure that the last call was a miss during testing.
101- #[ cfg( feature = "testing" ) ]
102- LAST_WAS_HIT . with ( |cell| cell. set ( false ) ) ;
103-
104- output
105- }
106-
10788/// Evict the global cache.
10889///
10990/// This removes all memoized results from the cache whose age is larger than or
You can’t perform that action at this time.
0 commit comments