File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -410,13 +410,7 @@ pub fn get_compile_benchmarks(
410
410
let mut skip = false ;
411
411
412
412
let name_matches = |prefixes : & mut HashMap < & str , usize > | {
413
- for ( prefix, n) in prefixes. iter_mut ( ) {
414
- if name. as_str ( ) . starts_with ( prefix) {
415
- * n += 1 ;
416
- return true ;
417
- }
418
- }
419
- false
413
+ substring_matches ( prefixes, |prefix| name. starts_with ( prefix) )
420
414
} ;
421
415
422
416
if let Some ( includes) = includes. as_mut ( ) {
@@ -462,3 +456,19 @@ pub fn get_compile_benchmarks(
462
456
463
457
Ok ( benchmarks)
464
458
}
459
+
460
+ /// Helper to verify if a benchmark name matches a given substring, like a prefix or a suffix. The
461
+ /// `predicate` closure will be passed each substring from `substrings` until it returns true, and
462
+ /// in that case the substring's number of uses in the map will be increased.
463
+ fn substring_matches (
464
+ substrings : & mut HashMap < & str , usize > ,
465
+ predicate : impl Fn ( & str ) -> bool ,
466
+ ) -> bool {
467
+ for ( substring, n) in substrings. iter_mut ( ) {
468
+ if predicate ( substring) {
469
+ * n += 1 ;
470
+ return true ;
471
+ }
472
+ }
473
+ false
474
+ }
You can’t perform that action at this time.
0 commit comments