Implement whitespace minification

This commit is contained in:
Wilson Lin 2021-08-06 17:33:56 +10:00
commit 383b2b3423
11 changed files with 211 additions and 69 deletions

View file

@ -41,7 +41,6 @@ pub struct ByNamespace {
}
impl ByNamespace {
#[inline(always)]
fn get(&self, ns: Namespace) -> Option<&AttrMapEntry> {
match ns {
Namespace::Html => self.html.as_ref(),
@ -53,12 +52,10 @@ impl ByNamespace {
pub struct AttrMap(HashMap<&'static [u8], ByNamespace>);
impl AttrMap {
#[inline(always)]
pub const fn new(map: HashMap<&'static [u8], ByNamespace>) -> AttrMap {
AttrMap(map)
}
#[inline(always)]
pub fn get(&self, ns: Namespace, tag: &[u8], attr: &[u8]) -> Option<&AttributeMinification> {
self.0.get(attr).and_then(|namespaces| namespaces.get(ns)).and_then(|entry| match entry {
AttrMapEntry::AllNamespaceElements(min) => Some(min),

View file

@ -59,7 +59,6 @@ pub struct Lookup {
impl std::ops::Index<u8> for Lookup {
type Output = bool;
#[inline(always)]
fn index(&self, c: u8) -> &Self::Output {
// \`c\` is definitely below 256 so it's always safe to directly index table without checking.
unsafe {