More clippy suggestions
This commit is contained in:
parent
28944e33a4
commit
db7ae23404
|
@ -97,7 +97,7 @@ impl std::ops::Index<u8> for Lookup {
|
|||
})
|
||||
.map(
|
||||
([name, points]) => `
|
||||
pub static ${name}: &'static Lookup = &Lookup {
|
||||
pub static ${name}: &Lookup = &Lookup {
|
||||
table: [${Array.from({ length: 256 }, (_, i) => points.includes(i)).join(
|
||||
", "
|
||||
)}],
|
||||
|
|
|
@ -26,10 +26,10 @@ for (const [encoded, entity] of Object.entries(entities)) {
|
|||
}
|
||||
|
||||
const output = `
|
||||
pub static SHORTER_ENCODED_ENTITIES_ENCODED: &[&'static [u8]] = &[
|
||||
pub static SHORTER_ENCODED_ENTITIES_ENCODED: &[&[u8]] = &[
|
||||
${shorterEncodedEntities.map(([encoded, _]) => encoded).join(",\n ")}
|
||||
];
|
||||
pub static SHORTER_ENCODED_ENTITIES_DECODED: &[&'static [u8]] = &[
|
||||
pub static SHORTER_ENCODED_ENTITIES_DECODED: &[&[u8]] = &[
|
||||
${shorterEncodedEntities.map(([_, decoded]) => decoded).join(",\n ")}
|
||||
];
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ export class TrieBuilder {
|
|||
|
||||
const name = `${this.name}_NODE_${this.nextId++}`;
|
||||
this.variables.push(
|
||||
`static ${name}: &'static crate::pattern::TrieNode<${this.valueType}> = ${varValue};`
|
||||
`static ${name}: &crate::pattern::TrieNode<${this.valueType}> = ${varValue};`
|
||||
);
|
||||
this.codeCache.set(varValue, name);
|
||||
return name;
|
||||
|
|
|
@ -65,15 +65,13 @@ pub fn minify_content(
|
|||
match n {
|
||||
NodeData::Element { name, .. } => {
|
||||
if index_of_last_nonempty_text_or_elem > -1 {
|
||||
match &mut previous_nodes[index_of_last_nonempty_text_or_elem as usize] {
|
||||
NodeData::Element {
|
||||
next_sibling_element_name,
|
||||
..
|
||||
} => {
|
||||
debug_assert!(next_sibling_element_name.is_empty());
|
||||
next_sibling_element_name.extend_from_slice(name);
|
||||
}
|
||||
_ => {}
|
||||
if let NodeData::Element {
|
||||
next_sibling_element_name,
|
||||
..
|
||||
} = &mut previous_nodes[index_of_last_nonempty_text_or_elem as usize]
|
||||
{
|
||||
debug_assert!(next_sibling_element_name.is_empty());
|
||||
next_sibling_element_name.extend_from_slice(name);
|
||||
};
|
||||
};
|
||||
found_first_text_or_elem = true;
|
||||
|
@ -106,9 +104,10 @@ pub fn minify_content(
|
|||
};
|
||||
}
|
||||
if trim && index_of_last_text_or_elem > -1 {
|
||||
match nodes.get_mut(index_of_last_text_or_elem as usize).unwrap() {
|
||||
NodeData::Text { value } => right_trim(value),
|
||||
_ => {}
|
||||
if let NodeData::Text { value } =
|
||||
nodes.get_mut(index_of_last_text_or_elem as usize).unwrap()
|
||||
{
|
||||
right_trim(value);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -59,10 +59,7 @@ impl<'c> Code<'c> {
|
|||
}
|
||||
|
||||
pub fn shift_if_next_not_in_lookup(&mut self, lookup: &'static Lookup) -> Option<u8> {
|
||||
let c = self
|
||||
.code
|
||||
.get(self.next)
|
||||
.filter(|&&n| !lookup[n]).copied();
|
||||
let c = self.code.get(self.next).filter(|&&n| !lookup[n]).copied();
|
||||
if c.is_some() {
|
||||
self.next += 1;
|
||||
};
|
||||
|
|
|
@ -59,10 +59,9 @@ impl<V: 'static + Copy> TrieNode<V> {
|
|||
None | Some(None) => break,
|
||||
};
|
||||
pos += 1;
|
||||
match node.value {
|
||||
Some(v) => value = Some(TrieNodeMatch::Found { len: pos, value: v }),
|
||||
None => {}
|
||||
};
|
||||
if let Some(v) = node.value {
|
||||
value = Some(TrieNodeMatch::Found { len: pos, value: v });
|
||||
}
|
||||
}
|
||||
value.unwrap_or(TrieNodeMatch::NotFound { reached: pos })
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue