diff --git a/crates/gosub_css3/src/tokenizer.rs b/crates/gosub_css3/src/tokenizer.rs index c0a215d37..5e015ff0e 100644 --- a/crates/gosub_css3/src/tokenizer.rs +++ b/crates/gosub_css3/src/tokenizer.rs @@ -904,7 +904,7 @@ impl<'stream> Tokenizer<'stream> { self.stream.seek(start); // todo: this is not efficient - let mut s = String::new(); + let mut s = String::with_capacity(end - start); for c in self.stream.get_slice(end - start) { if let Ch(c) = c { s.push(*c); diff --git a/crates/gosub_html5/src/tokenizer.rs b/crates/gosub_html5/src/tokenizer.rs index 9cf98b1c6..8dc239347 100644 --- a/crates/gosub_html5/src/tokenizer.rs +++ b/crates/gosub_html5/src/tokenizer.rs @@ -335,16 +335,13 @@ impl<'stream> Tokenizer<'stream> { } State::RCDATALessThanSign => { let c = self.read_char(); - match c { - Ch('/') => { - self.temporary_buffer.clear(); - self.state = State::RCDATAEndTagOpen; - } - _ => { - self.consume('<'); - self.stream_prev(); - self.state = State::RCDATA; - } + if let Ch('/') = c { + self.temporary_buffer.clear(); + self.state = State::RCDATAEndTagOpen; + } else { + self.consume('<'); + self.stream_prev(); + self.state = State::RCDATA; } } State::RCDATAEndTagOpen => { @@ -424,16 +421,13 @@ impl<'stream> Tokenizer<'stream> { } State::RAWTEXTLessThanSign => { let c = self.read_char(); - match c { - Ch('/') => { - self.temporary_buffer.clear(); - self.state = State::RAWTEXTEndTagOpen; - } - _ => { - self.consume('<'); - self.stream_prev(); - self.state = State::RAWTEXT; - } + if let Ch('/') = c { + self.temporary_buffer.clear(); + self.state = State::RAWTEXTEndTagOpen; + } else { + self.consume('<'); + self.stream_prev(); + self.state = State::RAWTEXT; } } State::RAWTEXTEndTagOpen => { @@ -1998,15 +1992,12 @@ impl<'stream> Tokenizer<'stream> { } State::CDATASectionBracket => { let c = self.read_char(); - match c { - Ch(']') => { - self.state = State::CDATASectionEnd; - } - _ => { - self.consume(']'); - self.stream_prev(); - self.state = State::CDATASection; - } + if let Ch(']') = c { + self.state = State::CDATASectionEnd; + } else { + self.consume(']'); + self.stream_prev(); + self.state = State::CDATASection; } } State::CDATASectionEnd => {