summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_extension.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-12 15:52:14 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-12 15:52:14 -0700
commit28c7844c1ef5ea0c8727b890e9ff56b593119a00 (patch)
treea96e31bbff3c221a0030e3a8a6501a5f81379d0f /core/fxcrt/fx_extension.cpp
parentade9465067098d9f94a13f61741cebf4bb8aac47 (diff)
downloadpdfium-28c7844c1ef5ea0c8727b890e9ff56b593119a00.tar.xz
Add CFX_ByteStringC::CharAt() to avoid c_str() and casts.
Most of the time, we want to operate on chars as if they were unsigned, but there are a few places where we need the default (questionably signed) values. Consolidate the casting in a single place rather than forcing callers to get a char* ptr. BUG=pdfium:493 Review-Url: https://codereview.chromium.org/1972053003
Diffstat (limited to 'core/fxcrt/fx_extension.cpp')
-rw-r--r--core/fxcrt/fx_extension.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 0b55fc91dd..315e33fd7e 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -219,17 +219,13 @@ int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) {
}
uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase) {
- const FX_CHAR* pStr = str.c_str();
- const FX_CHAR* pStrEnd = pStr + str.GetLength();
uint32_t dwHashCode = 0;
if (bIgnoreCase) {
- while (pStr < pStrEnd) {
- dwHashCode = 31 * dwHashCode + FXSYS_tolower(*pStr++);
- }
+ for (FX_STRSIZE i = 0; i < str.GetLength(); ++i)
+ dwHashCode = 31 * dwHashCode + FXSYS_tolower(str.CharAt(i));
} else {
- while (pStr < pStrEnd) {
- dwHashCode = 31 * dwHashCode + *pStr++;
- }
+ for (FX_STRSIZE i = 0; i < str.GetLength(); ++i)
+ dwHashCode = 31 * dwHashCode + str.CharAt(i);
}
return dwHashCode;
}