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

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1576033002: Merge to XFA: Use std::map as CPDF_Dictionary's underlying store. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 11 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
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 236ecaa837783d0dad71cbf83c0bcc2e6598c99f..3ab44231721195b40e94339bd16a444776dbb23a 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -869,11 +869,9 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
if (!pRoot ||
(pRef && IsValidObjectNumber(pRef->GetRefObjNum()) &&
m_ObjectInfo[pRef->GetRefObjNum()].pos != 0)) {
- FX_POSITION trailer_pos = pTrailer->GetStartPos();
- while (trailer_pos) {
- CFX_ByteString key;
- CPDF_Object* pElement =
- pTrailer->GetNextElement(trailer_pos, key);
+ for (const auto& it : *pTrailer) {
+ const CFX_ByteString& key = it.first;
+ CPDF_Object* pElement = it.second;
FX_DWORD dwObjNum =
pElement ? pElement->GetObjNum() : 0;
if (dwObjNum) {
@@ -2162,13 +2160,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList,
continue;
CFX_ByteStringC keyNoSlash(key.c_str() + 1, key.GetLength() - 1);
- // TODO(thestig): Remove this conditional once CPDF_Dictionary has a
- // better underlying map implementation.
- if (nKeys < 32) {
- pDict->SetAt(keyNoSlash, pObj);
- } else {
- pDict->AddValue(keyNoSlash, pObj);
- }
+ pDict->SetAt(keyNoSlash, pObj);
}
if (IsSignatureDict(pDict.get())) {
@@ -2315,8 +2307,8 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
return nullptr;
}
if (key.GetLength() > 1) {
- pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1),
- obj.release());
+ pDict->SetAt(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1),
+ obj.release());
}
}
if (pContext) {
@@ -3058,11 +3050,9 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(
if (pDict && pDict->GetString("Type") == "Page" && !bParsePage) {
continue;
}
- FX_POSITION pos = pDict->GetStartPos();
- while (pos) {
- CPDF_Object* value;
- CFX_ByteString key;
- value = pDict->GetNextElement(pos, key);
+ for (const auto& it : *pDict) {
+ const CFX_ByteString& key = it.first;
+ CPDF_Object* value = it.second;
if (key != "Parent") {
new_obj_array.Add(value);
}
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp ('k') | core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698