summaryrefslogtreecommitdiffstats
path: root/vendor/gix-attributes/src/search
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gix-attributes/src/search')
-rw-r--r--vendor/gix-attributes/src/search/mod.rs6
-rw-r--r--vendor/gix-attributes/src/search/outcome.rs40
2 files changed, 21 insertions, 25 deletions
diff --git a/vendor/gix-attributes/src/search/mod.rs b/vendor/gix-attributes/src/search/mod.rs
index f06928bf2..83c6d4192 100644
--- a/vendor/gix-attributes/src/search/mod.rs
+++ b/vendor/gix-attributes/src/search/mod.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;
-use byteyarn::Yarn;
+use kstring::KString;
use smallvec::SmallVec;
use crate::{Assignment, AssignmentRef};
@@ -99,7 +99,7 @@ pub struct Outcome {
/// A stack of attributes to use for processing attributes of matched patterns and for resolving their macros.
attrs_stack: SmallVec<[(AttributeId, Assignment, Option<AttributeId>); 8]>,
/// A set of attributes we should limit ourselves to, or empty if we should fill in all attributes, made of
- selected: SmallVec<[(Yarn, Option<AttributeId>); AVERAGE_NUM_ATTRS]>,
+ selected: SmallVec<[(KString, Option<AttributeId>); AVERAGE_NUM_ATTRS]>,
/// storage for all patterns we have matched so far (in order to avoid referencing them, we copy them, but only once).
patterns: RefMap<gix_glob::Pattern>,
/// storage for all assignments we have matched so far (in order to avoid referencing them, we copy them, but only once).
@@ -135,7 +135,7 @@ pub struct MetadataCollection {
/// A mapping of an attribute or macro name to its order, that is the time when it was *first* seen.
///
/// This is the inverse of the order attributes are searched.
- name_to_meta: HashMap<Yarn, Metadata>,
+ name_to_meta: HashMap<KString, Metadata>,
}
/// Metadata associated with an attribute or macro name.
diff --git a/vendor/gix-attributes/src/search/outcome.rs b/vendor/gix-attributes/src/search/outcome.rs
index 9ad8a81e1..7cea3bd19 100644
--- a/vendor/gix-attributes/src/search/outcome.rs
+++ b/vendor/gix-attributes/src/search/outcome.rs
@@ -1,6 +1,6 @@
use bstr::{BString, ByteSlice};
-use byteyarn::Yarn;
use gix_glob::Pattern;
+use kstring::{KString, KStringRef};
use crate::{
search::{
@@ -44,7 +44,7 @@ impl Outcome {
pub fn initialize_with_selection<'a>(
&mut self,
collection: &MetadataCollection,
- attribute_names: impl IntoIterator<Item = impl Into<&'a str>>,
+ attribute_names: impl IntoIterator<Item = impl Into<KStringRef<'a>>>,
) {
self.initialize_with_selection_inner(collection, &mut attribute_names.into_iter().map(Into::into))
}
@@ -52,15 +52,15 @@ impl Outcome {
fn initialize_with_selection_inner(
&mut self,
collection: &MetadataCollection,
- attribute_names: &mut dyn Iterator<Item = &str>,
+ attribute_names: &mut dyn Iterator<Item = KStringRef<'_>>,
) {
self.initialize(collection);
self.selected.clear();
self.selected.extend(attribute_names.map(|name| {
(
- Yarn::inlined(name).unwrap_or_else(|| name.to_string().into_boxed_str().into()),
- collection.name_to_meta.get(name).map(|meta| meta.id),
+ name.to_owned(),
+ collection.name_to_meta.get(name.as_str()).map(|meta| meta.id),
)
}));
self.reset_remaining();
@@ -176,12 +176,11 @@ impl Outcome {
source: Option<&std::path::PathBuf>,
sequence_number: usize,
) -> bool {
- self.attrs_stack.extend(attrs.filter_map(|attr| {
- self.matches_by_id[attr.id.0]
- .r#match
- .is_none()
- .then(|| (attr.id, attr.inner.clone(), None))
- }));
+ self.attrs_stack.extend(
+ attrs
+ .filter(|attr| self.matches_by_id[attr.id.0].r#match.is_none())
+ .map(|attr| (attr.id, attr.inner.clone(), None)),
+ );
while let Some((id, assignment, parent_order)) = self.attrs_stack.pop() {
let slot = &mut self.matches_by_id[id.0];
if slot.r#match.is_some() {
@@ -212,12 +211,12 @@ impl Outcome {
if is_macro {
// TODO(borrowchk): one fine day we should be able to re-borrow `slot` without having to redo the array access.
let slot = &self.matches_by_id[id.0];
- self.attrs_stack.extend(slot.macro_attributes.iter().filter_map(|attr| {
- self.matches_by_id[attr.id.0]
- .r#match
- .is_none()
- .then(|| (attr.id, attr.inner.clone(), Some(id)))
- }));
+ self.attrs_stack.extend(
+ slot.macro_attributes
+ .iter()
+ .filter(|attr| self.matches_by_id[attr.id.0].r#match.is_none())
+ .map(|attr| (attr.id, attr.inner.clone(), Some(id))),
+ );
}
}
false
@@ -315,7 +314,7 @@ impl MetadataCollection {
None => {
let order = AttributeId(self.name_to_meta.len());
self.name_to_meta.insert(
- Yarn::inlined(name).unwrap_or_else(|| name.to_string().into_boxed_str().into()),
+ KString::from_ref(name),
Metadata {
id: order,
macro_attributes: Default::default(),
@@ -335,10 +334,7 @@ impl MetadataCollection {
Some(meta) => meta.id,
None => {
let order = AttributeId(self.name_to_meta.len());
- self.name_to_meta.insert(
- Yarn::inlined(name).unwrap_or_else(|| name.to_string().into_boxed_str().into()),
- order.into(),
- );
+ self.name_to_meta.insert(KString::from_ref(name), order.into());
order
}
}