clang-tidy: don't use string compare

Found with readability-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2021-04-27 00:00:02 -07:00 committed by Luis Díaz Más
parent 8337462032
commit 143a1fbbe2
7 changed files with 17 additions and 20 deletions

View File

@ -41,7 +41,7 @@ void httpcon(const std::string& url, bool useHttp1_0 = false) {
if (!useHttp1_0) request["version"] = "1.1";
int serverCode = Exiv2::http(request,response,errors);
if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) {
if (serverCode < 0 || serverCode >= 400 || errors != "") {
throw Exiv2::Error(Exiv2::kerTiffDirectoryTooLarge, "Server", serverCode);
}
}

View File

@ -147,15 +147,12 @@ Jzon::Node& objectForKey(const std::string& Key,Jzon::Object& root,std::string&
bool isObject(std::string& value)
{
return !value.compare(std::string("type=\"Struct\""));
return value == std::string("type=\"Struct\"");
}
bool isArray(std::string& value)
{
return !value.compare(std::string("type=\"Seq\""))
|| !value.compare(std::string("type=\"Bag\""))
|| !value.compare(std::string("type=\"Alt\""))
;
return value == "type=\"Seq\"" || value == "type=\"Bag\"" || value == "type=\"Alt\"";
}
#define STORE(node,key,value) \

View File

@ -519,7 +519,7 @@ namespace Action {
bool result=Params::instance().keys_.empty();
for (auto k = Params::instance().keys_.begin(); !result && k != Params::instance().keys_.end(); ++k)
{
result = key.compare(*k) == 0;
result = key == *k;
}
return result ;
}

View File

@ -2072,7 +2072,7 @@ namespace Exiv2 {
request["port"] = hostInfo_.Port;
request["verb"] = "HEAD";
int serverCode = http(request, response, errors);
if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) {
if (serverCode < 0 || serverCode >= 400 || errors != "") {
throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path);
}
@ -2097,7 +2097,7 @@ namespace Exiv2 {
}
int serverCode = http(request, responseDic, errors);
if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) {
if (serverCode < 0 || serverCode >= 400 || errors != "") {
throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path);
}
response = responseDic["body"];
@ -2150,7 +2150,7 @@ namespace Exiv2 {
request["header"] = ss.str();
int serverCode = http(request, response, errors);
if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) {
if (serverCode < 0 || serverCode >= 400 || errors != "") {
throw Error(kerFileOpenFailed, "http",Exiv2::Internal::stringFormat("%d",serverCode), hostInfo_.Path);
}
}

View File

@ -1316,7 +1316,7 @@ namespace {
for (auto&& filename : cmdFiles) {
try {
std::ifstream file(filename.c_str());
bool bStdin = filename.compare("-") == 0;
bool bStdin = filename == "-";
if (!file && !bStdin) {
std::cerr << filename << ": " << _("Failed to open command file for reading\n");
return false;

View File

@ -277,7 +277,7 @@ namespace Exiv2 {
bool fileExists(const std::string& path, bool ct)
{
// special case: accept "-" (means stdin)
if (path.compare("-") == 0 || fileProtocol(path) != pFile) {
if (path == "-" || fileProtocol(path) != pFile) {
return true;
}

View File

@ -696,7 +696,7 @@ namespace Exiv2 {
bufRead = size;
done = !bExtXMP;
}
} else if (option == kpsIccProfile && signature.compare(iccId_) == 0) {
} else if (option == kpsIccProfile && signature == iccId_) {
// extract ICCProfile
if (size > 0) {
io_->seek(-bufRead, BasicIo::cur); // back to buffer (after marker)
@ -709,7 +709,7 @@ namespace Exiv2 {
#endif
bufRead = size;
}
} else if (option == kpsIptcErase && signature.compare("Photoshop 3.0") == 0) {
} else if (option == kpsIptcErase && signature == "Photoshop 3.0") {
// delete IPTC data segment from JPEG
if (size > 0) {
io_->seek(-bufRead, BasicIo::cur);
@ -720,7 +720,7 @@ namespace Exiv2 {
const size_t start = size > 0 ? 2 : 0;
const size_t end = start + (size > 32 ? 32 : size);
out << "| " << Internal::binaryToString(makeSlice(buf, start, end));
if (signature.compare(iccId_) == 0) {
if (signature == iccId_) {
// extract the chunk information from the buffer
//
// the buffer looks like this in this branch
@ -739,10 +739,10 @@ namespace Exiv2 {
// for MPF: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/MPF.html
// for FLIR: http://owl.phy.queensu.ca/~phil/exiftool/TagNames/FLIR.html
bool bFlir = option == kpsRecursive && marker == (app0_ + 1) && signature.compare("FLIR") == 0;
bool bExif = option == kpsRecursive && marker == (app0_ + 1) && signature.compare("Exif") == 0;
bool bMPF = option == kpsRecursive && marker == (app0_ + 2) && signature.compare("MPF") == 0;
bool bPS = option == kpsRecursive && signature.compare("Photoshop 3.0") == 0;
bool bFlir = option == kpsRecursive && marker == (app0_ + 1) && signature == "FLIR";
bool bExif = option == kpsRecursive && marker == (app0_ + 1) && signature == "Exif";
bool bMPF = option == kpsRecursive && marker == (app0_ + 2) && signature == "MPF";
bool bPS = option == kpsRecursive && signature == "Photoshop 3.0";
if (bFlir || bExif || bMPF || bPS) {
// extract Exif data block which is tiff formatted
if (size > 0) {
@ -755,7 +755,7 @@ namespace Exiv2 {
// copy the data to memory
io_->seek(-bufRead, BasicIo::cur);
io_->read(exif, size);
uint32_t start = signature.compare("Exif") == 0 ? 8 : 6;
uint32_t start = signature == "Exif" ? 8 : 6;
uint32_t max = (uint32_t)size - 1;
// is this an fff block?