Skip to content

Commit

Permalink
Avoid copying strings in sonarqube when sorting tests by file
Browse files Browse the repository at this point in the history
  • Loading branch information
horenmar committed Jan 29, 2023
1 parent 65ffee5 commit 60264b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/catch2/reporters/catch_reporter_sonarqube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace Catch {
}

void SonarQubeReporter::writeRun( TestRunNode const& runNode ) {
std::map<std::string, std::vector<TestCaseNode const*>> testsPerFile;
std::map<StringRef, std::vector<TestCaseNode const*>> testsPerFile;

for ( auto const& child : runNode.children ) {
testsPerFile[child->value.testInfo->lineInfo.file].push_back(
Expand All @@ -52,7 +52,7 @@ namespace Catch {
}
}

void SonarQubeReporter::writeTestFile(std::string const& filename, std::vector<TestCaseNode const*> const& testCaseNodes) {
void SonarQubeReporter::writeTestFile(StringRef filename, std::vector<TestCaseNode const*> const& testCaseNodes) {
XmlWriter::ScopedElement e = xml.scopedElement("file");
xml.writeAttribute("path"_sr, filename);

Expand Down
2 changes: 1 addition & 1 deletion src/catch2/reporters/catch_reporter_sonarqube.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Catch {

void writeRun( TestRunNode const& groupNode );

void writeTestFile(std::string const& filename, std::vector<TestCaseNode const*> const& testCaseNodes);
void writeTestFile(StringRef filename, std::vector<TestCaseNode const*> const& testCaseNodes);

void writeTestCase(TestCaseNode const& testCaseNode);

Expand Down

0 comments on commit 60264b8

Please sign in to comment.