From b8d4b9c6ea0c03e64490c268bf835cc3ec003462 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 30 Jan 2023 22:28:08 -0800 Subject: [PATCH] remove manual math Signed-off-by: Rosen Penev --- src/convert.cpp | 2 +- src/futils.cpp | 4 ++-- src/jpgimage.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/convert.cpp b/src/convert.cpp index 626c06a3..cd822a89 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1145,7 +1145,7 @@ void Converter::cnvXmpGPSCoord(const char* from, const char* to) { char sep1 = '\0'; char sep2 = '\0'; - value.erase(value.length() - 1); + value.pop_back(); std::istringstream in(value); diff --git a/src/futils.cpp b/src/futils.cpp index cccb0ded..38896ced 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -264,7 +264,7 @@ void Uri::Decode(Uri& uri) { Uri Uri::Parse(const std::string& uri) { Uri result; - if (!uri.length()) + if (uri.empty()) return result; auto uriEnd = uri.end(); @@ -320,7 +320,7 @@ Uri Uri::Parse(const std::string& uri) { auto portEnd = (pathStart != uriEnd) ? pathStart : queryStart; result.Port = std::string(hostEnd, portEnd); } - if (!result.Port.length() && result.Protocol == "http") + if (result.Port.empty() && result.Protocol == "http") result.Port = "80"; // path diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index 54f75044..68214091 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -200,8 +200,8 @@ void JpegBase::readMetadata() { // the first one (most jpegs only have one anyway). Comments // are simple single byte ISO-8859-1 strings. comment_.assign(buf.c_str(2), size - 2); - while (comment_.length() && comment_.at(comment_.length() - 1) == '\0') { - comment_.erase(comment_.length() - 1); + while (!comment_.empty() && comment_.back() == '\0') { + comment_.pop_back(); } --search; } else if (marker == app2_ && size >= 13 // prevent out-of-bounds read in memcmp on next line