Use reference instead of string copy (fixes some --style warnings from our code)

This commit is contained in:
Reijo Tomperi 2009-03-01 19:30:51 +00:00
parent 60b3bbdea4
commit d098b62975
3 changed files with 9 additions and 9 deletions

View File

@ -128,14 +128,14 @@ std::string ErrorLogger::ErrorMessage::toText() const
return text.str(); return text.str();
} }
void ErrorLogger::_writemsg(const Tokenizer *tokenizer, const Token *tok, const char severity[], const std::string msg, const std::string &id) void ErrorLogger::_writemsg(const Tokenizer *tokenizer, const Token *tok, const char severity[], const std::string &msg, const std::string &id)
{ {
std::list<const Token *> callstack; std::list<const Token *> callstack;
callstack.push_back(tok); callstack.push_back(tok);
_writemsg(tokenizer, callstack, severity, msg, id); _writemsg(tokenizer, callstack, severity, msg, id);
} }
void ErrorLogger::_writemsg(const Tokenizer *tokenizer, const std::list<const Token *> &callstack, const char severity[], const std::string msg, const std::string &id) void ErrorLogger::_writemsg(const Tokenizer *tokenizer, const std::list<const Token *> &callstack, const char severity[], const std::string &msg, const std::string &id)
{ {
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList; std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
for (std::list<const Token *>::const_iterator tok = callstack.begin(); tok != callstack.end(); ++tok) for (std::list<const Token *>::const_iterator tok = callstack.begin(); tok != callstack.end(); ++tok)
@ -150,7 +150,7 @@ void ErrorLogger::_writemsg(const Tokenizer *tokenizer, const std::list<const To
} }
void ErrorLogger::_writemsg(const std::string msg, const std::string &id) void ErrorLogger::_writemsg(const std::string &msg, const std::string &id)
{ {
std::ostringstream xml; std::ostringstream xml;
xml << "<error"; xml << "<error";

View File

@ -491,8 +491,8 @@ public:
static std::string callStackToString(const std::list<ErrorLogger::ErrorMessage::FileLocation> &callStack); static std::string callStackToString(const std::list<ErrorLogger::ErrorMessage::FileLocation> &callStack);
private: private:
void _writemsg(const Tokenizer *tokenizer, const Token *tok, const char severity[], const std::string msg, const std::string &id); void _writemsg(const Tokenizer *tokenizer, const Token *tok, const char severity[], const std::string &msg, const std::string &id);
void _writemsg(const Tokenizer *tokenizer, const std::list<const Token *> &callstack, const char severity[], const std::string msg, const std::string &id); void _writemsg(const Tokenizer *tokenizer, const std::list<const Token *> &callstack, const char severity[], const std::string &msg, const std::string &id);
void _writemsg(const std::string msg, const std::string &id); void _writemsg(const std::string &msg, const std::string &id);
}; };
#endif #endif

View File

@ -225,9 +225,9 @@ int main()
fout << " static std::string callStackToString(const std::list<ErrorLogger::ErrorMessage::FileLocation> &callStack);\n"; fout << " static std::string callStackToString(const std::list<ErrorLogger::ErrorMessage::FileLocation> &callStack);\n";
fout << "\n"; fout << "\n";
fout << "private:\n"; fout << "private:\n";
fout << " void _writemsg(const Tokenizer *tokenizer, const Token *tok, const char severity[], const std::string msg, const std::string &id);\n"; fout << " void _writemsg(const Tokenizer *tokenizer, const Token *tok, const char severity[], const std::string &msg, const std::string &id);\n";
fout << " void _writemsg(const Tokenizer *tokenizer, const std::list<const Token *> &callstack, const char severity[], const std::string msg, const std::string &id);\n"; fout << " void _writemsg(const Tokenizer *tokenizer, const std::list<const Token *> &callstack, const char severity[], const std::string &msg, const std::string &id);\n";
fout << " void _writemsg(const std::string msg, const std::string &id);\n"; fout << " void _writemsg(const std::string &msg, const std::string &id);\n";
fout << "};\n"; fout << "};\n";
fout << "#endif\n"; fout << "#endif\n";
std::cout << std::endl; std::cout << std::endl;