rinja-rs / rinja

A template rendering engine based on Jinja, generating type-safe Rust code at compile time.
https://rinja.readthedocs.io
Apache License 2.0
28 stars 4 forks source link

Generator: reduce amount of intermediate allocations #11

Closed Kijewski closed 2 weeks ago

Kijewski commented 2 weeks ago

No need to allocate a String, just to write it into another String afterwards. This PR replaces the usages for format!() with format_args!().

GuillaumeGomez commented 2 weeks ago

That makes me think that we should add a way to bench performance impact somehow (not memory, too unlikely to be useful).

Kijewski commented 2 weeks ago

Is it possible to (repeatedly) call rinja_generator::derive_template() in "normal" code? If so, then I guess benchmarking would be easy. Otherwise, I guess it would be mostly a benchmark for your harddisk and the filesystem cache. :/

GuillaumeGomez commented 2 weeks ago

I thought we could use something like we have here. We can do an include_str! and then call the parser on it in the bench I think?

GuillaumeGomez commented 2 weeks ago

I opened #12 and #13 so it's not forgotten. I think it's really minor improvements so not a priority at all, but could still be interesting. :)