Resolves 3 instances of the following issue:
the 'empty' method should be used to check for emptiness instead of
'size' (readability-container-size-empty)
PiperOrigin-RevId: 501665722
Change-Id: I12e6dc708ec7b80bee594813bb954ab36e55b4b5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/103253
Commit-Queue: Lei Zhang <thestig@chromium.org>
Commit-Queue: Andrew Weintraub <asweintraub@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 242f4a0..d3e1cc0 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -183,7 +183,7 @@
ByteString::ByteString(const fxcrt::ostringstream& outStream) {
auto str = outStream.str();
- if (str.size() > 0)
+ if (!str.empty())
m_pData.Reset(StringData::Create(str.c_str(), str.size()));
}
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index 168e3eb..67cd3ff 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -58,7 +58,7 @@
explicit constexpr StringViewTemplate(
const pdfium::span<const CharType>& other) noexcept
- : m_Span(other.size()
+ : m_Span(!other.empty()
? reinterpret_cast<const UnsignedType*>(other.data())
: nullptr,
other.size()) {}
@@ -67,7 +67,7 @@
!std::is_same<UnsignedType, CharType>::value>::type>
constexpr StringViewTemplate(
const pdfium::span<const UnsignedType>& other) noexcept
- : m_Span(other.size() ? other.data() : nullptr, other.size()) {}
+ : m_Span(!other.empty() ? other.data() : nullptr, other.size()) {}
// Deliberately implicit to avoid calling on every char literal.
// |ch| must be an lvalue that outlives the StringViewTemplate.