From bbdb000c55f82dc12f87a43f68defdfc246c6e51 Mon Sep 17 00:00:00 2001 From: Clemens Wasser Date: Tue, 25 Jan 2022 21:27:27 +0100 Subject: GlobalNinjaGenerator: enlarge file stream buffer --- Source/cmGlobalNinjaGenerator.cxx | 13 +++++++++++++ Source/cmGlobalNinjaGenerator.h | 1 + 2 files changed, 14 insertions(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 19c4ee3..614cb66 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1021,6 +1021,19 @@ bool cmGlobalNinjaGenerator::OpenBuildFileStreams() return false; } + // New buffer size 8 MiB + constexpr auto buildFileStreamBufferSize = 8 * 1024 * 1024; + + // Ensure the buffer is allocated + if (!this->BuildFileStreamBuffer) { + this->BuildFileStreamBuffer = + cm::make_unique(buildFileStreamBufferSize); + } + + // Enlarge the internal buffer of the `BuildFileStream` + this->BuildFileStream->rdbuf()->pubsetbuf(this->BuildFileStreamBuffer.get(), + buildFileStreamBufferSize); + // Write a comment about this file. *this->BuildFileStream << "# This file contains all the build statements describing the\n" diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 84fc06c..98442bf 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -526,6 +526,7 @@ private: /// The file containing the build statement. (the relationship of the /// compilation DAG). std::unique_ptr BuildFileStream; + std::unique_ptr BuildFileStreamBuffer; /// The file containing the rule statements. (The action attached to each /// edge of the compilation DAG). std::unique_ptr RulesFileStream; -- cgit v0.12