|
1 | | -use crate::{node::Node, specificity::Specificity}; |
| 1 | +use crate::{node::Node, priority::Priority}; |
2 | 2 |
|
3 | 3 | impl<S> Node<S> { |
4 | 4 | /// Optimizes the tree structure. |
5 | 5 | pub(crate) fn optimize(&mut self) { |
6 | | - self.optimize_inner(Specificity::default()); |
| 6 | + self.optimize_inner(Priority::default()); |
7 | 7 | } |
8 | 8 |
|
9 | 9 | /// Recursively optimizes nodes from root to leaf. |
10 | 10 | /// We can skip optimization if the current node hasn't changed. |
11 | | - fn optimize_inner(&mut self, parent: Specificity) { |
| 11 | + fn optimize_inner(&mut self, parent: Priority) { |
12 | 12 | if !self.needs_optimization { |
13 | 13 | return; |
14 | 14 | } |
15 | 15 |
|
16 | 16 | if let Some(data) = &mut self.data { |
17 | | - data.specificity = parent.clone(); |
| 17 | + data.priority = parent.clone(); |
18 | 18 | } |
19 | 19 |
|
20 | 20 | for child in &mut self.static_children { |
21 | | - let child_specificity = parent.clone().with_static(child.state.prefix.len()); |
22 | | - child.optimize_inner(child_specificity); |
| 21 | + let child_priority = parent.clone().with_static(child.state.prefix.len()); |
| 22 | + child.optimize_inner(child_priority); |
23 | 23 | } |
24 | 24 |
|
25 | 25 | for child in &mut self.dynamic_children { |
26 | | - let child_specificity = parent.clone().with_dynamic(); |
27 | | - child.optimize_inner(child_specificity); |
| 26 | + let child_priority = parent.clone().with_dynamic(); |
| 27 | + child.optimize_inner(child_priority); |
28 | 28 | } |
29 | 29 |
|
30 | 30 | for child in &mut self.wildcard_children { |
31 | | - let child_specificity = parent.clone().with_wildcard(); |
32 | | - child.optimize_inner(child_specificity); |
| 31 | + let child_priority = parent.clone().with_wildcard(); |
| 32 | + child.optimize_inner(child_priority); |
33 | 33 | } |
34 | 34 |
|
35 | 35 | if let Some(child) = &mut self.end_wildcard { |
36 | | - let child_specificity = parent.with_wildcard(); |
37 | | - child.optimize_inner(child_specificity); |
| 36 | + let child_priority = parent.with_wildcard(); |
| 37 | + child.optimize_inner(child_priority); |
38 | 38 | } |
39 | 39 |
|
40 | 40 | self.static_children.sort(); |
|
0 commit comments