mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-15 19:55:39 +02:00
Store tags in one big pre-allocated string and only work with refs
This should decrease the number of allocations before main is entered significantly, but complicates the code somewhat in return. Assuming I used `massif` right, doing just `SelfTest --list-tests` went from 929 allocations at "Remove gcc-4.9 from the travis builds" (2 commits up), to 614 allocations with this commit.
This commit is contained in:
@@ -48,12 +48,17 @@ namespace Catch {
|
||||
return std::string(timeStamp);
|
||||
}
|
||||
|
||||
std::string fileNameTag(const std::vector<std::string> &tags) {
|
||||
std::string fileNameTag(std::vector<Tag> const& tags) {
|
||||
auto it = std::find_if(begin(tags),
|
||||
end(tags),
|
||||
[] (std::string const& tag) {return tag.front() == '#'; });
|
||||
if (it != tags.end())
|
||||
return it->substr(1);
|
||||
[] (Tag const& tag) {
|
||||
return tag.original.size() > 0
|
||||
&& tag.original[0] == '#'; });
|
||||
if (it != tags.end()) {
|
||||
return static_cast<std::string>(
|
||||
it->original.substr(1, it->original.size() - 1)
|
||||
);
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
@@ -312,7 +312,7 @@ namespace Catch {
|
||||
auto aliasTag = m_xml.scopedElement("Aliases");
|
||||
for (auto const& alias : tag.spellings) {
|
||||
m_xml.startElement("Alias", XmlFormatting::Indent)
|
||||
.writeText(alias, XmlFormatting::None)
|
||||
.writeText(static_cast<std::string>(alias), XmlFormatting::None)
|
||||
.endElement(XmlFormatting::Newline);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user