mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-06 01:02:55 +00:00
Minor code stlye change in the Facet::is_prefix_of. (#1449)
This commit is contained in:
@@ -152,11 +152,14 @@ impl Facet {
|
||||
|
||||
/// Returns `true` if other is a subfacet of `self`.
|
||||
pub fn is_prefix_of(&self, other: &Facet) -> bool {
|
||||
// Root is a prefix of every other path.
|
||||
// This is not just an optimisation. It is necessary for correctness.
|
||||
if self.is_root() {
|
||||
return true;
|
||||
}
|
||||
let self_str = self.encoded_str();
|
||||
let other_str = other.encoded_str();
|
||||
self_str.len() < other_str.len()
|
||||
&& other_str.starts_with(self_str)
|
||||
&& (self_str.len() == 0 || other_str.as_bytes()[self_str.len()] == FACET_SEP_BYTE)
|
||||
other_str.starts_with(self_str) && other_str.as_bytes()[self_str.len()] == FACET_SEP_BYTE
|
||||
}
|
||||
|
||||
/// Extract path from the `Facet`.
|
||||
|
||||
Reference in New Issue
Block a user