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 32
32
F : FnOnce ( In ) -> Out ,
33
33
{
34
34
// Early bypass if memoization is disabled.
35
- // Hopefully the compiler will optimize this away, if the condition is constant.
36
35
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;
38
43
}
39
44
40
45
// Compute the hash of the input's key part.
80
85
output
81
86
}
82
87
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
-
107
88
/// Evict the global cache.
108
89
///
109
90
/// 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