diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-08-18 09:20:29 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-08-18 09:20:29 -0700 |
commit | 85d5c4af4a9546970b34dd413c473d10fef8534b (patch) | |
tree | b993a0309a69b5c31c122971be04d062e3ae341c /core/src/fpdfapi/fpdf_font/ttgsubtable.cpp | |
parent | 57207efd5f17ec63e174061ea5415afb58516fce (diff) | |
download | pdfium-85d5c4af4a9546970b34dd413c473d10fef8534b.tar.xz |
FX_CMapDwordToDword considered harmful.
Lookups are log(n), but random insertions could result in n^2
behaviour. Replace with maps and sets.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1289703003 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_font/ttgsubtable.cpp')
-rw-r--r-- | core/src/fpdfapi/fpdf_font/ttgsubtable.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp index a1717a9fd4..81383fa869 100644 --- a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp +++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp @@ -85,33 +85,26 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(TT_uint32_t glyphnum, k); if (FeatureList.FeatureRecord[index].FeatureTag == tag[0] || FeatureList.FeatureRecord[index].FeatureTag == tag[1]) { - FX_DWORD value; - if (!m_featureMap.Lookup(index, value)) { - m_featureMap.SetAt(index, index); + if (m_featureMap.find(index) == m_featureMap.end()) { + m_featureMap[index] = index; } } } } } - if (!m_featureMap.GetStartPosition()) { + if (m_featureMap.empty()) { for (int i = 0; i < FeatureList.FeatureCount; i++) { if (FeatureList.FeatureRecord[i].FeatureTag == tag[0] || FeatureList.FeatureRecord[i].FeatureTag == tag[1]) { - FX_DWORD value; - if (!m_featureMap.Lookup(i, value)) { - m_featureMap.SetAt(i, i); - } + m_featureMap[i] = i; } } } m_bFeautureMapLoad = TRUE; } - FX_POSITION pos = m_featureMap.GetStartPosition(); - while (pos) { - FX_DWORD index, value; - m_featureMap.GetNextAssoc(pos, index, value); + for (const auto& pair : m_featureMap) { if (GetVerticalGlyphSub(glyphnum, vglyphnum, - &FeatureList.FeatureRecord[value].Feature)) { + &FeatureList.FeatureRecord[pair.second].Feature)) { return true; } } |