serge-sans-paille created this revision. serge-sans-paille added reviewers: vsk, arphaman. Herald added subscribers: cfe-commits, dexonsmith. Herald added a project: clang. serge-sans-paille edited the summary of this revision.
Avoiding an intermediate join operation, which in turns removes the need for an intermediate buffer that may be quite large, as showcased by https://bugs.llvm.org/show_bug.cgi?id=41965 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D62623 Files: clang/lib/CodeGen/CoverageMappingGen.cpp Index: clang/lib/CodeGen/CoverageMappingGen.cpp =================================================================== --- clang/lib/CodeGen/CoverageMappingGen.cpp +++ clang/lib/CodeGen/CoverageMappingGen.cpp @@ -1388,10 +1388,12 @@ std::string FilenamesAndCoverageMappings; llvm::raw_string_ostream OS(FilenamesAndCoverageMappings); CoverageFilenamesSectionWriter(FilenameRefs).write(OS); - std::string RawCoverageMappings = - llvm::join(CoverageMappings.begin(), CoverageMappings.end(), ""); - OS << RawCoverageMappings; - size_t CoverageMappingSize = RawCoverageMappings.size(); + + size_t CoverageMappingSize = 0; + for (auto &S : CoverageMappings) { + CoverageMappingSize += S.size(); + OS << std::move(S); + } size_t FilenamesSize = OS.str().size() - CoverageMappingSize; // Append extra zeroes if necessary to ensure that the size of the filenames // and coverage mappings is a multiple of 8.
Index: clang/lib/CodeGen/CoverageMappingGen.cpp =================================================================== --- clang/lib/CodeGen/CoverageMappingGen.cpp +++ clang/lib/CodeGen/CoverageMappingGen.cpp @@ -1388,10 +1388,12 @@ std::string FilenamesAndCoverageMappings; llvm::raw_string_ostream OS(FilenamesAndCoverageMappings); CoverageFilenamesSectionWriter(FilenameRefs).write(OS); - std::string RawCoverageMappings = - llvm::join(CoverageMappings.begin(), CoverageMappings.end(), ""); - OS << RawCoverageMappings; - size_t CoverageMappingSize = RawCoverageMappings.size(); + + size_t CoverageMappingSize = 0; + for (auto &S : CoverageMappings) { + CoverageMappingSize += S.size(); + OS << std::move(S); + } size_t FilenamesSize = OS.str().size() - CoverageMappingSize; // Append extra zeroes if necessary to ensure that the size of the filenames // and coverage mappings is a multiple of 8.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits