diff --git a/gen/codepoints.ts b/gen/codepoints.ts index 8ffef28..0c1f1aa 100644 --- a/gen/codepoints.ts +++ b/gen/codepoints.ts @@ -97,7 +97,7 @@ impl std::ops::Index 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( ", " )}], diff --git a/gen/entities.ts b/gen/entities.ts index 76804bf..2ae650b 100644 --- a/gen/entities.ts +++ b/gen/entities.ts @@ -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 ")} ]; diff --git a/gen/trie.ts b/gen/trie.ts index 7563e07..5240b6d 100644 --- a/gen/trie.ts +++ b/gen/trie.ts @@ -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; diff --git a/src/minify/content.rs b/src/minify/content.rs index 01c7264..1e3d097 100644 --- a/src/minify/content.rs +++ b/src/minify/content.rs @@ -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); }; } diff --git a/src/parse/mod.rs b/src/parse/mod.rs index cd6474d..44adba3 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -59,10 +59,7 @@ impl<'c> Code<'c> { } pub fn shift_if_next_not_in_lookup(&mut self, lookup: &'static Lookup) -> Option { - 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; }; diff --git a/src/pattern.rs b/src/pattern.rs index 844a554..94f6e29 100644 --- a/src/pattern.rs +++ b/src/pattern.rs @@ -59,10 +59,9 @@ impl TrieNode { 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 }) }