servo / html5ever

High-performance browser-grade HTML5 parser
Other
2.14k stars 222 forks source link

Stop allocating string for rcdom example #503

Closed domfarolino closed 1 year ago

domfarolino commented 1 year ago

As a Rust noob, I think this is the simplest way to stop string allocations for the indentation, but I'd love to know if there is a better way to do this. I believe .collect::<String>() in the old code was causing a String allocation, and I think a simplified version that I almost went with (print!("{}", " ".repeat(indent));) would do the same thing, so I think this PR should be sufficient.

/cc @jdm