Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: core/src/fxge/ge/fx_ge_text.cpp

Issue 1301793002: Merge to XFA: CFX_MapByteStringToPtr considered harmful (combo patch). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxge/ge/fx_ge_linux.cpp ('k') | fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxge/ge/fx_ge_text.cpp
diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp
index 0bb8eab8122cfd13c629f846be23ff087fdf85f4..93e3486b7965dbc18e945f6f71dd015ce746fe04 100644
--- a/core/src/fxge/ge/fx_ge_text.cpp
+++ b/core/src/fxge/ge/fx_ge_text.cpp
@@ -1204,15 +1204,11 @@ CFX_FaceCache::CFX_FaceCache(FXFT_Face face) {
m_Face = face;
}
CFX_FaceCache::~CFX_FaceCache() {
- FX_POSITION pos = m_SizeMap.GetStartPosition();
- CFX_ByteString Key;
- CFX_SizeGlyphCache* pSizeCache = NULL;
- while (pos) {
- m_SizeMap.GetNextAssoc(pos, Key, (void*&)pSizeCache);
- delete pSizeCache;
+ for (const auto& pair : m_SizeMap) {
+ delete pair.second;
}
- m_SizeMap.RemoveAll();
- pos = m_PathMap.GetStartPosition();
+ m_SizeMap.clear();
+ FX_POSITION pos = m_PathMap.GetStartPosition();
void* key1;
CFX_PathData* pPath;
while (pos) {
@@ -1232,13 +1228,13 @@ CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(
FX_BOOL bFontStyle,
int dest_width,
int anti_alias) {
- CFX_SizeGlyphCache* pSizeCache = NULL;
- if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) {
+ CFX_SizeGlyphCache* pSizeCache;
+ auto it = m_SizeMap.find(FaceGlyphsKey);
+ if (it == m_SizeMap.end()) {
pSizeCache = new CFX_SizeGlyphCache;
- if (pSizeCache == NULL) {
- return NULL;
- }
- m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
+ m_SizeMap[FaceGlyphsKey] = pSizeCache;
+ } else {
+ pSizeCache = it->second;
}
CFX_GlyphBitmap* pGlyphBitmap = NULL;
if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index,
@@ -1310,8 +1306,9 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(
bFontStyle, dest_width, anti_alias);
}
CFX_GlyphBitmap* pGlyphBitmap;
- CFX_SizeGlyphCache* pSizeCache = NULL;
- if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) {
+ auto it = m_SizeMap.find(FaceGlyphsKey);
+ if (it != m_SizeMap.end()) {
+ CFX_SizeGlyphCache* pSizeCache = it->second;
if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index,
(void*&)pGlyphBitmap)) {
return pGlyphBitmap;
@@ -1326,8 +1323,8 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(
pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix,
dest_width, anti_alias);
if (pGlyphBitmap) {
- pSizeCache = new CFX_SizeGlyphCache;
- m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
+ CFX_SizeGlyphCache* pSizeCache = new CFX_SizeGlyphCache;
+ m_SizeMap[FaceGlyphsKey] = pSizeCache;
pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap);
return pGlyphBitmap;
}
« no previous file with comments | « core/src/fxge/ge/fx_ge_linux.cpp ('k') | fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698