@@ -73,6 +73,7 @@ impl Default for TopRatedsMetadata {
73
73
pub struct MinimizerScheduler < CS , F , M > {
74
74
base : CS ,
75
75
skip_non_favored_prob : u64 ,
76
+ remove_metadata : bool ,
76
77
phantom : PhantomData < ( F , M ) > ,
77
78
}
78
79
@@ -293,7 +294,7 @@ where
293
294
old_meta. refcnt ( ) <= 0
294
295
} ;
295
296
296
- if must_remove {
297
+ if must_remove && self . remove_metadata {
297
298
drop ( old. metadata_map_mut ( ) . remove :: < M > ( ) ) ;
298
299
}
299
300
}
@@ -304,7 +305,7 @@ where
304
305
* meta. refcnt_mut ( ) = new_favoreds. len ( ) as isize ;
305
306
}
306
307
307
- if new_favoreds. is_empty ( ) {
308
+ if new_favoreds. is_empty ( ) && self . remove_metadata {
308
309
drop (
309
310
state
310
311
. corpus ( )
@@ -368,10 +369,25 @@ where
368
369
369
370
/// Creates a new [`MinimizerScheduler`] that wraps a `base` [`Scheduler`]
370
371
/// and has a default probability to skip non-faved [`Testcase`]s of [`DEFAULT_SKIP_NON_FAVORED_PROB`].
372
+ /// This will remove the metadata `M` when it is no longer needed, after consumption. This might
373
+ /// for example be a `MapIndexesMetadata`.
371
374
pub fn new ( base : CS ) -> Self {
372
375
Self {
373
376
base,
374
377
skip_non_favored_prob : DEFAULT_SKIP_NON_FAVORED_PROB ,
378
+ remove_metadata : true ,
379
+ phantom : PhantomData ,
380
+ }
381
+ }
382
+
383
+ /// Creates a new [`MinimizerScheduler`] that wraps a `base` [`Scheduler`]
384
+ /// and has a default probability to skip non-faved [`Testcase`]s of [`DEFAULT_SKIP_NON_FAVORED_PROB`].
385
+ /// This method will prevent the metadata `M` from being removed at the end of scoring.
386
+ pub fn non_metadata_removing ( base : CS ) -> Self {
387
+ Self {
388
+ base,
389
+ skip_non_favored_prob : DEFAULT_SKIP_NON_FAVORED_PROB ,
390
+ remove_metadata : false ,
375
391
phantom : PhantomData ,
376
392
}
377
393
}
@@ -382,6 +398,7 @@ where
382
398
Self {
383
399
base,
384
400
skip_non_favored_prob,
401
+ remove_metadata : true ,
385
402
phantom : PhantomData ,
386
403
}
387
404
}
0 commit comments