Skip to content

Commit e2204a9

Browse files
committed
Speed up split_ns_and_tag
1 parent bd56ce6 commit e2204a9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

native/meeseeks_html5ever_nif/src/flat_dom.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,10 @@ impl NifEncoder for Parent {
363363
// Node
364364

365365
fn split_ns_and_tag(ns_tag: &str) -> (&str, &str) {
366-
let v: Vec<&str> = ns_tag.splitn(2, ":").collect();
367-
match v.len() {
368-
1 => ("", v[0]),
369-
2 => (v[0], v[1]),
370-
_ => unreachable!(),
366+
let first_colon = ns_tag.find(':').unwrap_or_else(|| ns_tag.len());
367+
match ns_tag.split_at(first_colon) {
368+
(tag, "") => ("", tag),
369+
(ns, tag) => (ns, &tag[1..]),
371370
}
372371
}
373372

0 commit comments

Comments
 (0)