summaryrefslogtreecommitdiff
path: root/xfa/fde/css/fde_cssdeclaration.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-19 21:06:16 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-19 21:06:16 -0700
commit788ac38e25fc6c000b36ec1722764673e192dea3 (patch)
tree53cca2497138207f7f9e6366b945fa5e20ac6e85 /xfa/fde/css/fde_cssdeclaration.cpp
parent8b45eb1443e5a31f6f172fa16169b9b56177b639 (diff)
downloadpdfium-788ac38e25fc6c000b36ec1722764673e192dea3.tar.xz
Use std::unordered_map for CFDE_CSSStyleSheet::m_StringCache
Get rid of some LPC typedefs while we're at it. Review-Url: https://codereview.chromium.org/1990363003
Diffstat (limited to 'xfa/fde/css/fde_cssdeclaration.cpp')
-rw-r--r--xfa/fde/css/fde_cssdeclaration.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/xfa/fde/css/fde_cssdeclaration.cpp b/xfa/fde/css/fde_cssdeclaration.cpp
index f4f55fc0db..570b60c670 100644
--- a/xfa/fde/css/fde_cssdeclaration.cpp
+++ b/xfa/fde/css/fde_cssdeclaration.cpp
@@ -53,26 +53,21 @@ const FX_WCHAR* CFDE_CSSDeclaration::CopyToLocal(
const FX_WCHAR* pszValue,
int32_t iValueLen) {
ASSERT(iValueLen > 0);
- CFX_MapPtrToPtr* pCache = pArgs->pStringCache;
- void* pKey = NULL;
+ std::unordered_map<uint32_t, FX_WCHAR*>* pCache = pArgs->pStringCache;
+ uint32_t key = 0;
if (pCache) {
- void* pszCached = NULL;
- pKey = (void*)(uintptr_t)FX_HashCode_GetW(
- CFX_WideStringC(pszValue, iValueLen), false);
- if (pCache->Lookup(pKey, pszCached)) {
- return (const FX_WCHAR*)pszCached;
- }
+ key = FX_HashCode_GetW(CFX_WideStringC(pszValue, iValueLen), false);
+ auto it = pCache->find(key);
+ if (it != pCache->end())
+ return it->second;
}
FX_WCHAR* psz =
(FX_WCHAR*)pArgs->pStaticStore->Alloc((iValueLen + 1) * sizeof(FX_WCHAR));
- if (psz == NULL) {
- return NULL;
- }
FXSYS_wcsncpy(psz, pszValue, iValueLen);
psz[iValueLen] = '\0';
- if (pCache) {
- pCache->SetAt(pKey, psz);
- }
+ if (pCache)
+ (*pCache)[key] = psz;
+
return psz;
}
IFDE_CSSPrimitiveValue* CFDE_CSSDeclaration::NewNumberValue(