summaryrefslogtreecommitdiffstats
path: root/src/configimpl.l
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-03-28 11:58:30 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-03-28 12:25:48 (GMT)
commitc48639744a6fa118b9851b307107994ba93ce4c8 (patch)
tree8917c567f8f00560fba4554ade2b7e79bbe3ff45 /src/configimpl.l
parentcef71dc4fcfca9e3580214c39f20dc538ed6b2d9 (diff)
downloadDoxygen-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/configimpl.l')
-rw-r--r--src/configimpl.l49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/configimpl.l b/src/configimpl.l
index 6f22061..bde2290 100644
--- a/src/configimpl.l
+++ b/src/configimpl.l
@@ -40,6 +40,7 @@
#include "configoptions.h"
#include "fileinfo.h"
#include "dir.h"
+#include "textstream.h"
#define YY_NO_INPUT 1
#define YY_NO_UNISTD_H 1
@@ -127,18 +128,18 @@ static QCString convertToComment(const QCString &s, const QCString &u)
return result;
}
-void ConfigOption::writeBoolValue(std::ostream &t,bool v)
+void ConfigOption::writeBoolValue(TextStream &t,bool v)
{
t << " ";
if (v) t << "YES"; else t << "NO";
}
-void ConfigOption::writeIntValue(std::ostream &t,int i)
+void ConfigOption::writeIntValue(TextStream &t,int i)
{
t << " " << i;
}
-void ConfigOption::writeStringValue(std::ostream &t,const QCString &s)
+void ConfigOption::writeStringValue(TextStream &t,const QCString &s)
{
char c;
bool needsEscaping=FALSE;
@@ -169,7 +170,7 @@ void ConfigOption::writeStringValue(std::ostream &t,const QCString &s)
}
}
-void ConfigOption::writeStringList(std::ostream &t,const StringVector &l)
+void ConfigOption::writeStringList(TextStream &t,const StringVector &l)
{
bool first=TRUE;
for (const auto &p : l)
@@ -321,7 +322,7 @@ bool &ConfigImpl::getBool(const char *fileName,int num,const char *name) const
/* ------------------------------------------ */
-void ConfigInfo::writeTemplate(std::ostream &t, bool sl,bool)
+void ConfigInfo::writeTemplate(TextStream &t, bool sl,bool)
{
if (!sl)
{
@@ -332,7 +333,7 @@ void ConfigInfo::writeTemplate(std::ostream &t, bool sl,bool)
t << "#---------------------------------------------------------------------------\n";
}
-void ConfigList::writeTemplate(std::ostream &t,bool sl,bool)
+void ConfigList::writeTemplate(TextStream &t,bool sl,bool)
{
if (!sl)
{
@@ -349,12 +350,12 @@ void ConfigList::writeTemplate(std::ostream &t,bool sl,bool)
t << "\n";
}
-void ConfigList::compareDoxyfile(std::ostream &t)
+void ConfigList::compareDoxyfile(TextStream &t)
{
auto get_stripped = [](std::string s) { return QCString(s.c_str()).stripWhiteSpace(); };
auto is_not_empty = [get_stripped](std::string s) { return !get_stripped(s).isEmpty(); };
- int defCnt = std::count_if( m_value.begin(), m_value.end(),is_not_empty);
- int valCnt = std::count_if(m_defaultValue.begin(),m_defaultValue.end(),is_not_empty);
+ size_t defCnt = std::count_if( m_value.begin(), m_value.end(),is_not_empty);
+ size_t valCnt = std::count_if(m_defaultValue.begin(),m_defaultValue.end(),is_not_empty);
if ( valCnt != defCnt)
{
writeTemplate(t,TRUE,TRUE);
@@ -382,7 +383,7 @@ void ConfigList::compareDoxyfile(std::ostream &t)
}
}
-void ConfigEnum::writeTemplate(std::ostream &t,bool sl,bool)
+void ConfigEnum::writeTemplate(TextStream &t,bool sl,bool)
{
if (!sl)
{
@@ -399,12 +400,12 @@ void ConfigEnum::writeTemplate(std::ostream &t,bool sl,bool)
t << "\n";
}
-void ConfigEnum::compareDoxyfile(std::ostream &t)
+void ConfigEnum::compareDoxyfile(TextStream &t)
{
if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE);
}
-void ConfigString::writeTemplate(std::ostream &t,bool sl,bool)
+void ConfigString::writeTemplate(TextStream &t,bool sl,bool)
{
if (!sl)
{
@@ -421,12 +422,12 @@ void ConfigString::writeTemplate(std::ostream &t,bool sl,bool)
t << "\n";
}
-void ConfigString::compareDoxyfile(std::ostream &t)
+void ConfigString::compareDoxyfile(TextStream &t)
{
if (m_value.stripWhiteSpace() != m_defValue.stripWhiteSpace()) writeTemplate(t,TRUE,TRUE);
}
-void ConfigInt::writeTemplate(std::ostream &t,bool sl,bool upd)
+void ConfigInt::writeTemplate(TextStream &t,bool sl,bool upd)
{
if (!sl)
{
@@ -450,12 +451,12 @@ void ConfigInt::writeTemplate(std::ostream &t,bool sl,bool upd)
t << "\n";
}
-void ConfigInt::compareDoxyfile(std::ostream &t)
+void ConfigInt::compareDoxyfile(TextStream &t)
{
if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE);
}
-void ConfigBool::writeTemplate(std::ostream &t,bool sl,bool upd)
+void ConfigBool::writeTemplate(TextStream &t,bool sl,bool upd)
{
if (!sl)
{
@@ -480,13 +481,13 @@ void ConfigBool::writeTemplate(std::ostream &t,bool sl,bool upd)
t << "\n";
}
-void ConfigBool::compareDoxyfile(std::ostream &t)
+void ConfigBool::compareDoxyfile(TextStream &t)
{
if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE);
}
-void ConfigObsolete::writeTemplate(std::ostream &,bool,bool) {}
-void ConfigDisabled::writeTemplate(std::ostream &,bool,bool) {}
+void ConfigObsolete::writeTemplate(TextStream &,bool,bool) {}
+void ConfigDisabled::writeTemplate(TextStream &,bool,bool) {}
/* -----------------------------------------------------------------
*
@@ -1082,7 +1083,7 @@ static void readIncludeFile(const char *incName)
/*@ ----------------------------------------------------------------------------
*/
-void ConfigImpl::writeTemplate(std::ostream &t,bool sl,bool upd)
+void ConfigImpl::writeTemplate(TextStream &t,bool sl,bool upd)
{
/* print first lines of user comment that were at the beginning of the file, might have special meaning for editors */
if (m_startComment)
@@ -1106,7 +1107,7 @@ void ConfigImpl::writeTemplate(std::ostream &t,bool sl,bool upd)
}
}
-void ConfigImpl::compareDoxyfile(std::ostream &t)
+void ConfigImpl::compareDoxyfile(TextStream &t)
{
t << "# Difference with default Doxyfile " << getFullVersion();
t << "\n";
@@ -1307,7 +1308,7 @@ static QCString configFileToString(const char *name)
std::string ret;
char buffer[4096];
while (in.read(buffer, sizeof(buffer))) ret.append(buffer, sizeof(buffer));
- ret.append(buffer, in.gcount());
+ ret.append(buffer, static_cast<uint>(in.gcount()));
if (!ret.empty() && ret[ret.length()-1]!='\n') ret+='\n'; // to help the scanner
return ret;
};
@@ -2062,12 +2063,12 @@ void Config::checkAndCorrect()
}
-void Config::writeTemplate(std::ostream &t,bool shortList,bool update)
+void Config::writeTemplate(TextStream &t,bool shortList,bool update)
{
ConfigImpl::instance()->writeTemplate(t,shortList,update);
}
-void Config::compareDoxyfile(std::ostream &t)
+void Config::compareDoxyfile(TextStream &t)
{
postProcess(FALSE, TRUE);
ConfigImpl::instance()->compareDoxyfile(t);