clang-tidy: run through performance checks

Found with performance*

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 4 years ago committed by Luis Díaz Más
parent b8712188bb
commit f9d394adf0

@ -175,8 +175,7 @@ public:
@return value
*/
std::string Get(std::string section, std::string name,
std::string default_value);
std::string Get(const std::string& section, const std::string& name, const std::string& default_value);
/*! @brief Get an integer (long) value from INI file, returning default_value if
not found or not a valid integer (decimal "1234", "-1234", or hex "0x4d2").
@ -187,7 +186,7 @@ public:
@return value
*/
long GetInteger(std::string section, std::string name, long default_value);
long GetInteger(const std::string& section, const std::string& name, long default_value);
/*! @brief Get a real (floating point double) value from INI file, returning
default_value if not found or not a valid floating point value
@ -199,7 +198,7 @@ public:
@return value
*/
double GetReal(std::string section, std::string name, double default_value);
double GetReal(const std::string& section, const std::string& name, double default_value);
/*! @brief Get a boolean value from INI file, returning default_value if not found or if
not a valid true/false value. Valid true values are "true", "yes", "on", "1",
@ -211,12 +210,13 @@ public:
@return value
*/
bool GetBoolean(std::string section, std::string name, bool default_value);
bool GetBoolean(const std::string& section, const std::string& name, bool default_value);
private:
int _error; //!< status
std::map<std::string, std::string> _values; //!< values from file
static std::string MakeKey(std::string section, std::string name); //!< return key encoded from section/name
static std::string MakeKey(const std::string& section,
const std::string& name); //!< return key encoded from section/name
static int ValueHandler(void* user, const char* section, const char* name,
const char* value); //!< value handler
};

@ -458,7 +458,7 @@ namespace Jzon
{
children.push_back(NamedNodePtr(name, node.GetCopy()));
}
void Object::Add(const std::string &name, Value node)
void Object::Add(const std::string &name, const Value &node)
{
children.push_back(NamedNodePtr(name, new Value(node)));
}
@ -570,7 +570,7 @@ namespace Jzon
{
children.push_back(node.GetCopy());
}
void Array::Add(Value node)
void Array::Add(const Value &node)
{
children.push_back(new Value(node));
}

@ -251,9 +251,9 @@ namespace Jzon
Type GetType() const override;
void Add(const std::string &name, Node &node);
void Add(const std::string &name, Value node);
void Remove(const std::string &name);
void Clear();
void Add(const std::string &name, const Value &node);
void Remove(const std::string &name);
void Clear();
iterator begin();
const_iterator begin() const;
@ -319,9 +319,9 @@ namespace Jzon
Type GetType() const override;
void Add(Node &node);
void Add(Value node);
void Remove(size_t index);
void Clear();
void Add(const Value &node);
void Remove(size_t index);
void Clear();
iterator begin();
const_iterator begin() const;

@ -91,7 +91,7 @@ bool getToken(std::string& in,Token& token, std::set<std::string>* pNS=NULL)
return result;
}
Jzon::Node& addToTree(Jzon::Node& r1,Token token)
Jzon::Node& addToTree(Jzon::Node& r1, const Token& token)
{
Jzon::Object object ;
Jzon::Array array ;

@ -670,7 +670,7 @@ bool sina(const char* s,const char** a)
return bResult;
}
int readFile(const char* path,Options /* options */)
int readFile(const char* path, const Options& /* options */)
{
FILE* f = fopen(path,"r");
int nResult = f ? typeFile : typeUnknown;

@ -87,7 +87,7 @@ int main()
// -----
// Copy constructor
ExifKey ek2(ek);
const ExifKey& ek2(ek);
// operator<<
tc += 1;

@ -68,8 +68,7 @@ int main(int argc, char* argv[])
std::istringstream input(tags.str()) ;
while (std::getline(input, line)) {
std::cout << groupList->groupName_ << "."
<< (item == "all" ? line.substr(0,line.find(",")) : line)
<< std::endl;
<< (item == "all" ? line.substr(0, line.find(',')) : line) << std::endl;
}
groupList++;
}

@ -150,7 +150,7 @@ namespace {
with
os << make_pair( myString, width)
*/
std::ostream& operator<<( std::ostream& os, std::pair<std::string, int> strAndWidth);
std::ostream& operator<<(std::ostream& os, const std::pair<std::string, int>& strAndWidth);
//! Print image Structure information
int printStructure(std::ostream& out, Exiv2::PrintStructureOption option, const std::string &path);
@ -2175,7 +2175,7 @@ namespace {
return 0;
}
std::ostream& operator<<( std::ostream& os, std::pair<std::string, int> strAndWidth)
std::ostream& operator<<(std::ostream& os, const std::pair<std::string, int>& strAndWidth)
{
const std::string& str( strAndWidth.first);
size_t minChCount( strAndWidth.second);

@ -238,13 +238,13 @@ int INIReader::ParseError() const
return _error;
}
string INIReader::Get(string section, string name, string default_value)
string INIReader::Get(const string& section, const string& name, const string& default_value)
{
string key = MakeKey(section, name);
return _values.count(key) ? _values[key] : default_value;
}
long INIReader::GetInteger(string section, string name, long default_value)
long INIReader::GetInteger(const string& section, const string& name, long default_value)
{
string valstr = Get(section, name, "");
const char* value = valstr.c_str();
@ -254,7 +254,7 @@ long INIReader::GetInteger(string section, string name, long default_value)
return end > value ? n : default_value;
}
double INIReader::GetReal(string section, string name, double default_value)
double INIReader::GetReal(const string& section, const string& name, double default_value)
{
string valstr = Get(section, name, "");
const char* value = valstr.c_str();
@ -263,7 +263,7 @@ double INIReader::GetReal(string section, string name, double default_value)
return end > value ? n : default_value;
}
bool INIReader::GetBoolean(string section, string name, bool default_value)
bool INIReader::GetBoolean(const string& section, const string& name, bool default_value)
{
string valstr = Get(section, name, "");
// Convert to lower case to make string comparisons case-insensitive
@ -275,7 +275,7 @@ bool INIReader::GetBoolean(string section, string name, bool default_value)
return default_value;
}
string INIReader::MakeKey(string section, string name)
string INIReader::MakeKey(const string& section, const string& name)
{
string key = section + "=" + name;
// Convert to lower case to make section/name lookups case-insensitive

@ -240,10 +240,7 @@ namespace Exiv2 {
} // PngChunk::parsePngChunk
void PngChunk::parseChunkContent( Image* pImage,
const byte* key,
long keySize,
const DataBuf arr)
void PngChunk::parseChunkContent(Image* pImage, const byte* key, long keySize, const DataBuf& arr)
{
// We look if an ImageMagick EXIF raw profile exist.

@ -131,10 +131,7 @@ namespace Exiv2 {
Xmp packet generated by Adobe ==> Image Xmp metadata.
Description string ==> Image Comments.
*/
static void parseChunkContent( Image* pImage,
const byte* key,
long keySize,
const DataBuf arr);
static void parseChunkContent(Image* pImage, const byte* key, long keySize, const DataBuf& arr);
/*!
@brief Return a compressed (zTXt) or uncompressed (tEXt) PNG ASCII text chunk

@ -119,7 +119,7 @@ namespace Exiv2 {
return b;
}
static bool matchi(const std::string key,const char* substr)
static bool matchi(const std::string& key, const char* substr)
{
return toLowerCase(key).find(substr) != std::string::npos;
}

@ -75,7 +75,7 @@ TEST_F(AXmpKey, correctlyInstantiatedWithValidPrefixAndProperty)
TEST_F(AXmpKey, canBeCopiedConstructed)
{
XmpKey key(expectedPrefix, expectedProperty);
XmpKey copiedKey(key);
const XmpKey& copiedKey(key);
checkValidity(copiedKey);
}

Loading…
Cancel
Save