Fix some nits in string code.

Change-Id: I79fc14855e61fddcded01d5b706f5a4713cf07d7
Reviewed-on: https://pdfium-review.googlesource.com/c/46611
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 660f376..d56bdef 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -425,8 +425,7 @@
     return 0;
 
   size_t old_length = m_pData->m_nDataLength;
-  if (count == 0 ||
-      index != pdfium::clamp(index, static_cast<size_t>(0), old_length))
+  if (count == 0 || index != pdfium::clamp<size_t>(index, 0, old_length))
     return old_length;
 
   size_t removal_length = index + count;
@@ -518,7 +517,7 @@
 }
 
 size_t ByteString::Insert(size_t location, char ch) {
-  const size_t cur_length = m_pData ? m_pData->m_nDataLength : 0;
+  const size_t cur_length = GetLength();
   if (!IsValidLength(location))
     return cur_length;
 
@@ -588,7 +587,7 @@
 }
 
 size_t ByteString::Remove(char chRemove) {
-  if (!m_pData || m_pData->m_nDataLength < 1)
+  if (!m_pData || m_pData->m_nDataLength == 0)
     return 0;
 
   char* pstrSource = m_pData->m_String;
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index a58a5c9..49f82a6 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -593,8 +593,7 @@
     return 0;
 
   size_t old_length = m_pData->m_nDataLength;
-  if (count == 0 ||
-      index != pdfium::clamp(index, static_cast<size_t>(0), old_length))
+  if (count == 0 || index != pdfium::clamp<size_t>(index, 0, old_length))
     return old_length;
 
   size_t removal_length = index + count;
@@ -730,7 +729,7 @@
 }
 
 size_t WideString::Insert(size_t location, wchar_t ch) {
-  const size_t cur_length = m_pData ? m_pData->m_nDataLength : 0;
+  const size_t cur_length = GetLength();
   if (!IsValidLength(location))
     return cur_length;
 
@@ -788,7 +787,7 @@
 }
 
 size_t WideString::Remove(wchar_t chRemove) {
-  if (!m_pData || m_pData->m_nDataLength < 1)
+  if (!m_pData || m_pData->m_nDataLength == 0)
     return 0;
 
   wchar_t* pstrSource = m_pData->m_String;