1
+ use std:: ops;
2
+
1
3
use rustc_hash:: FxHashMap ;
2
4
3
5
use crate :: IngredientIndex ;
@@ -7,10 +9,6 @@ use super::{accumulated::Accumulated, Accumulator, AnyAccumulated};
7
9
#[ derive( Default , Debug ) ]
8
10
pub struct AccumulatedMap {
9
11
map : FxHashMap < IngredientIndex , Box < dyn AnyAccumulated > > ,
10
-
11
- /// [`InputAccumulatedValues::Empty`] if any input read during the query's execution
12
- /// has any direct or indirect accumulated values.
13
- inputs : InputAccumulatedValues ,
14
12
}
15
13
16
14
impl AccumulatedMap {
@@ -21,21 +19,6 @@ impl AccumulatedMap {
21
19
. accumulate ( value) ;
22
20
}
23
21
24
- /// Adds the accumulated state of an input to this accumulated map.
25
- pub ( crate ) fn add_input ( & mut self , input : InputAccumulatedValues ) {
26
- if input. is_any ( ) {
27
- self . inputs = InputAccumulatedValues :: Any ;
28
- }
29
- }
30
-
31
- /// Returns whether an input of the associated query has any accumulated values.
32
- ///
33
- /// Note: Use [`InputAccumulatedValues::from_map`] to check if the associated query itself
34
- /// or any of its inputs has accumulated values.
35
- pub ( crate ) fn inputs ( & self ) -> InputAccumulatedValues {
36
- self . inputs
37
- }
38
-
39
22
pub fn extend_with_accumulated < A : Accumulator > (
40
23
& self ,
41
24
index : IngredientIndex ,
@@ -50,6 +33,10 @@ impl AccumulatedMap {
50
33
. unwrap ( )
51
34
. extend_with_accumulated ( output) ;
52
35
}
36
+
37
+ pub fn is_empty ( & self ) -> bool {
38
+ self . map . is_empty ( )
39
+ }
53
40
}
54
41
55
42
impl Clone for AccumulatedMap {
@@ -60,7 +47,6 @@ impl Clone for AccumulatedMap {
60
47
. iter ( )
61
48
. map ( |( & key, value) | ( key, value. cloned ( ) ) )
62
49
. collect ( ) ,
63
- inputs : self . inputs ,
64
50
}
65
51
}
66
52
}
@@ -70,7 +56,7 @@ impl Clone for AccumulatedMap {
70
56
/// Knowning whether any input has accumulated values makes aggregating the accumulated values
71
57
/// cheaper because we can skip over entire subtrees.
72
58
#[ derive( Copy , Clone , Debug , Default ) ]
73
- pub ( crate ) enum InputAccumulatedValues {
59
+ pub enum InputAccumulatedValues {
74
60
/// The query nor any of its inputs have any accumulated values.
75
61
#[ default]
76
62
Empty ,
@@ -80,14 +66,6 @@ pub(crate) enum InputAccumulatedValues {
80
66
}
81
67
82
68
impl InputAccumulatedValues {
83
- pub ( crate ) fn from_map ( accumulated : & AccumulatedMap ) -> Self {
84
- if accumulated. map . is_empty ( ) {
85
- accumulated. inputs
86
- } else {
87
- Self :: Any
88
- }
89
- }
90
-
91
69
pub ( crate ) const fn is_any ( self ) -> bool {
92
70
matches ! ( self , Self :: Any )
93
71
}
@@ -96,3 +74,11 @@ impl InputAccumulatedValues {
96
74
matches ! ( self , Self :: Empty )
97
75
}
98
76
}
77
+
78
+ impl ops:: BitOrAssign for InputAccumulatedValues {
79
+ fn bitor_assign ( & mut self , rhs : Self ) {
80
+ if rhs. is_any ( ) {
81
+ * self = Self :: Any ;
82
+ }
83
+ }
84
+ }
0 commit comments