@@ -413,20 +413,20 @@ impl Queue {
413
413
pub fn dequeue < P > (
414
414
& mut self ,
415
415
partial_key : & ProjectKey ,
416
- f : P ,
416
+ predicate : P ,
417
417
) -> Vec < ( Box < Envelope > , EnvelopeContext ) >
418
418
where
419
419
P : Fn ( & QueueKey ) -> bool ,
420
420
{
421
421
let mut result = Vec :: new ( ) ;
422
422
423
- let mut keys = self . index . remove ( partial_key) . unwrap_or_default ( ) ;
423
+ let mut queue_keys = self . index . remove ( partial_key) . unwrap_or_default ( ) ;
424
424
let mut index = BTreeSet :: new ( ) ;
425
425
426
- while let Some ( queue_key) = keys . pop_first ( ) {
426
+ while let Some ( queue_key) = queue_keys . pop_first ( ) {
427
427
// Find those keys which match predicates and return keys into the index, where
428
428
// predicate is failing.
429
- if f ( & queue_key) {
429
+ if predicate ( & queue_key) {
430
430
if let Some ( envelopes) = self . buffer . remove ( & queue_key) {
431
431
result. extend ( envelopes) ;
432
432
}
@@ -541,24 +541,18 @@ impl ProjectCacheBroker {
541
541
}
542
542
543
543
let envelopes = self . pending_envelopes . dequeue ( & project_key, |queue_key| {
544
- // Pick envelopes which belong to the incoming project.
545
- for key in & [ queue_key . root_key , queue_key. sampling_key ] {
546
- if project_key == * key {
547
- continue ;
548
- }
544
+ let partial_key = if queue_key . root_key == project_key {
545
+ queue_key. sampling_key
546
+ } else {
547
+ queue_key . root_key
548
+ } ;
549
549
550
- // We return false if project is not cached or its state is invalid.
551
- if self
552
- . projects
553
- . get ( & queue_key. sampling_key )
554
- // Make sure we have only cached and valid state.
555
- . and_then ( |p| p. valid_state ( ) )
556
- . map_or ( true , |s| s. invalid ( ) )
557
- {
558
- return false ;
559
- }
560
- }
561
- true
550
+ // We return false if project is not cached or its state is invalid, true otherwise.
551
+ self . projects
552
+ . get ( & partial_key)
553
+ // Make sure we have only cached and valid state.
554
+ . and_then ( |p| p. valid_state ( ) )
555
+ . map_or ( false , |s| !s. invalid ( ) )
562
556
} ) ;
563
557
564
558
// Flush envelopes where both states have resolved.
0 commit comments