Skip to content

Commit

Permalink
Simplify AnnotationMap::find
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Apr 16, 2023
1 parent 62863ed commit df2428f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/re_viewer/src/ui/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ impl AnnotationMap {
}

// Search through the all prefixes of this entity path until we find a
// matching annotation. If we find nothing return the default `MISSING_ANNOTATIONS`.
pub fn find<'a>(&self, entity_path: impl Into<&'a EntityPath>) -> Arc<Annotations> {
let mut next_parent = Some(entity_path.into().clone());
// matching annotation. If we find nothing return the default [`MISSING_ANNOTATIONS`].
pub fn find(&self, entity_path: &EntityPath) -> Arc<Annotations> {
let mut next_parent = Some(entity_path.clone());
while let Some(parent) = next_parent {
if let Some(legend) = self.0.get(&parent) {
return legend.clone();
}

next_parent = parent.parent().clone();
next_parent = parent.parent();
}

// Otherwise return the missing legend
Expand Down

0 comments on commit df2428f

Please sign in to comment.