Skip to content

Commit

Permalink
Small fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Jun 25, 2024
1 parent 40747ff commit 69f4c79
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 30 deletions.
2 changes: 1 addition & 1 deletion crates/gosub_css3/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
49 changes: 20 additions & 29 deletions crates/gosub_html5/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit 69f4c79

Please sign in to comment.