From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/gix-attributes/src/search/mod.rs | 6 ++--- vendor/gix-attributes/src/search/outcome.rs | 40 +++++++++++++---------------- 2 files changed, 21 insertions(+), 25 deletions(-) (limited to 'vendor/gix-attributes/src/search') 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); 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); AVERAGE_NUM_ATTRS]>, + selected: SmallVec<[(KString, Option); 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, /// 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, + name_to_meta: HashMap, } /// 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>, + attribute_names: impl IntoIterator>>, ) { 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, + attribute_names: &mut dyn Iterator>, ) { 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 } } -- cgit v1.2.3