Store Opt/Arg hint and description as StringRef

There is no good reason for these to be std::strings, as these
are just (optional) constants for nice user output. This ends up
reducing the allocations significantly.

When measuring allocations when running no tests, the changes are
`tests/SelfTest` 9213 -> 7705
`tests/ExtraTests/NoTests` 3723 -> 2215
This commit is contained in:
Martin Hořeňovský
2023-12-23 16:02:37 +01:00
parent 2b69a3e216
commit 2295d2c8cc
2 changed files with 12 additions and 11 deletions

View File

@@ -185,7 +185,7 @@ namespace Catch {
}
if (!m_hint.empty())
oss << " <" << m_hint << '>';
return { { oss.str(), m_description } };
return { { oss.str(), static_cast<std::string>(m_description) } };
}
bool Opt::isMatch(std::string const& optToken) const {