std::string parameters for debug::indent() and debug::dedent() in generated code
Closed this issue · 1 comments
awelzel commented
Separate follow up to #1589 . Looking at the generate code for the following grammar:
type K = unit {
x: skip bytes &size=1;
};
type L = unit {
k: K;
};
type M = unit {
l: L;
};
public type N = unit {
: M[] &eod;
};
There's a number of indent()
and dedent()
calls generated involving std::string
instances being constructed at runtime. These are pretty short strings so they shouldn't involve an allocation and might be optimized well, but might still be sensible to not even construct them.
try {
::hilti::rt::debug::indent(std::string("spicy"));
std::optional<::hilti::rt::stream::SafeConstIterator> __begin = std::make_optional(__cur.begin());
::hilti::rt::debug::dedent(std::string("spicy"));
A flamegraph indicates ~3.3% samples falling into basic_string functions.
Unfortunately I don't have the means to provide before-after here.