Optimize handling of --append=<file> option (execution time, memory)
Whitespace was removed from the append data for every configuration and every file: n(configuration) * n(files). Removing whitespace immediately after the append data was read can significantly reduce the execution time and memory usage. It also allows further improvement because copies to the temporary object appendCode are no longer needed. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
d11f18b5df
commit
785bc3d04b
|
@ -234,9 +234,7 @@ unsigned int CppCheck::processFile()
|
|||
_errorLogger.reportOut(std::string("Checking ") + fixedpath + ": " + cfg + std::string("..."));
|
||||
}
|
||||
|
||||
std::string appendCode = _settings.append();
|
||||
if (!appendCode.empty())
|
||||
Preprocessor::preprocessWhitespaces(appendCode);
|
||||
const std::string &appendCode = _settings.append();
|
||||
|
||||
if (_settings.debugFalsePositive) {
|
||||
if (findError(codeWithoutCfg + appendCode, _filename.c_str())) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "settings.h"
|
||||
#include "path.h"
|
||||
#include "preprocessor.h" // Preprocessor
|
||||
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
|
@ -129,10 +130,11 @@ bool Settings::append(const std::string &filename)
|
|||
while (std::getline(fin, line)) {
|
||||
_append += line + "\n";
|
||||
}
|
||||
Preprocessor::preprocessWhitespaces(_append);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Settings::append() const
|
||||
const std::string &Settings::append() const
|
||||
{
|
||||
return _append;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
bool append(const std::string &filename);
|
||||
|
||||
/** @brief get append code (--append) */
|
||||
std::string append() const;
|
||||
const std::string &append() const;
|
||||
|
||||
/** @brief Maximum number of configurations to check before bailing.
|
||||
Default is 12. (--max-configs=N) */
|
||||
|
|
Loading…
Reference in New Issue