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/docsets.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/docsets.cpp')
-rw-r--r-- | src/docsets.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/docsets.cpp b/src/docsets.cpp index 6040277..66ef115 100644 --- a/src/docsets.cpp +++ b/src/docsets.cpp @@ -27,12 +27,15 @@ #include "memberdef.h" #include "namespacedef.h" #include "util.h" +#include "textstream.h" struct DocSets::Private { QCString indent(); - std::ofstream nts; - std::ofstream tts; + std::ofstream ntf; + TextStream nts; + std::ofstream ttf; + TextStream tts; std::stack<bool> indentStack; std::set<std::string> scopes; }; @@ -148,11 +151,12 @@ void DocSets::initialize() // -- start Nodes.xml QCString notes = Config_getString(HTML_OUTPUT) + "/Nodes.xml"; - p->nts.open(notes.str(),std::ofstream::out | std::ofstream::binary); - if (!p->nts.is_open()) + p->ntf.open(notes.str(),std::ofstream::out | std::ofstream::binary); + if (!p->ntf.is_open()) { term("Could not open file %s for writing\n",notes.data()); } + p->nts.setStream(&p->ntf); //QCString indexName=Config_getBool(GENERATE_TREEVIEW)?"main":"index"; QCString indexName="index"; p->nts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; @@ -165,11 +169,12 @@ void DocSets::initialize() p->indentStack.push(true); QCString tokens = Config_getString(HTML_OUTPUT) + "/Tokens.xml"; - p->tts.open(tokens.str(),std::ofstream::out | std::ofstream::binary); - if (!p->tts.is_open()) + p->ttf.open(tokens.str(),std::ofstream::out | std::ofstream::binary); + if (!p->ttf.is_open()) { term("Could not open file %s for writing\n",tokens.data()); } + p->tts.setStream(&p->ttf); p->tts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; p->tts << "<Tokens version=\"1.0\">\n"; } @@ -185,10 +190,12 @@ void DocSets::finalize() p->nts << " </Node>\n"; p->nts << " </TOC>\n"; p->nts << "</DocSetNodes>\n"; - p->nts.close(); + p->nts.flush(); + p->ntf.close(); p->tts << "</Tokens>\n"; - p->tts.close(); + p->tts.flush(); + p->ttf.close(); } QCString DocSets::Private::indent() @@ -476,7 +483,7 @@ void DocSets::addIndexItem(const Definition *context,const MemberDef *md, } } -void DocSets::writeToken(std::ostream &t, +void DocSets::writeToken(TextStream &t, const Definition *d, const QCString &type, const QCString &lang, |