From 788ac38e25fc6c000b36ec1722764673e192dea3 Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 19 May 2016 21:06:16 -0700 Subject: 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 --- xfa/fde/css/fde_cssdeclaration.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'xfa/fde/css/fde_cssdeclaration.cpp') 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* 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( -- cgit v1.2.3