diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2021-03-28 11:58:30 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2021-03-28 12:25:48 (GMT) |
commit | c48639744a6fa118b9851b307107994ba93ce4c8 (patch) | |
tree | 8917c567f8f00560fba4554ade2b7e79bbe3ff45 /src/outputgen.cpp | |
parent | cef71dc4fcfca9e3580214c39f20dc538ed6b2d9 (diff) | |
download | Doxygen-c48639744a6fa118b9851b307107994ba93ce4c8.zip Doxygen-c48639744a6fa118b9851b307107994ba93ce4c8.tar.gz Doxygen-c48639744a6fa118b9851b307107994ba93ce4c8.tar.bz2 |
Refactoring: Add TextStream buffer to improve output writing performance
- direct use of std::stringstream and std::ostream gave a 30%
drop in performance.
Diffstat (limited to 'src/outputgen.cpp')
-rw-r--r-- | src/outputgen.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/outputgen.cpp b/src/outputgen.cpp index d922a93..ff03498 100644 --- a/src/outputgen.cpp +++ b/src/outputgen.cpp @@ -24,7 +24,7 @@ #include "message.h" #include "portable.h" -OutputGenerator::OutputGenerator(const char *dir) : t(nullptr), m_dir(dir) +OutputGenerator::OutputGenerator(const char *dir) : m_t(nullptr), m_dir(dir) { //printf("OutputGenerator::OutputGenerator()\n"); } @@ -34,12 +34,12 @@ OutputGenerator::~OutputGenerator() //printf("OutputGenerator::~OutputGenerator()\n"); } -OutputGenerator::OutputGenerator(const OutputGenerator &og) : t(nullptr) +OutputGenerator::OutputGenerator(const OutputGenerator &og) : m_t(nullptr) { m_dir = og.m_dir; // we don't copy the other fields. // after copying startPlainFile() should be called - if (og.t.rdbuf()!=nullptr) + if (og.m_t.stream()!=nullptr) { throw std::runtime_error("OutputGenerator copy constructor called while a file is processing"); } @@ -50,7 +50,7 @@ OutputGenerator &OutputGenerator::operator=(const OutputGenerator &og) m_dir = og.m_dir; // we don't copy the other fields. // after assignment startPlainFile() should be called - if (og.t.rdbuf()!=nullptr) + if (og.m_t.stream()!=nullptr) { throw std::runtime_error("OutputGenerator assignment operator called while a file is processing"); } @@ -66,12 +66,13 @@ void OutputGenerator::startPlainFile(const char *name) { term("Could not open file %s for writing\n",m_fileName.data()); } - t.rdbuf(m_file.rdbuf()); + m_t.setStream(&m_file); } void OutputGenerator::endPlainFile() { - t.rdbuf(nullptr); + m_t.flush(); + m_t.setStream(nullptr); m_file.close(); m_fileName.resize(0); } |