| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/include/fpdfapi/fpdf_objects.h" | 7 #include "core/include/fpdfapi/fpdf_objects.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey, | 727 void CPDF_Dictionary::ReplaceKey(const CFX_ByteStringC& oldkey, |
| 728 const CFX_ByteStringC& newkey) { | 728 const CFX_ByteStringC& newkey) { |
| 729 ASSERT(m_Type == PDFOBJ_DICTIONARY); | 729 ASSERT(m_Type == PDFOBJ_DICTIONARY); |
| 730 auto old_it = m_Map.find(oldkey); | 730 auto old_it = m_Map.find(oldkey); |
| 731 if (old_it == m_Map.end()) | 731 if (old_it == m_Map.end()) |
| 732 return; | 732 return; |
| 733 | 733 |
| 734 // Avoid 2 constructions of CFX_ByteString. | 734 // Avoid 2 constructions of CFX_ByteString. |
| 735 CFX_ByteString newkey_bytestring = newkey; | 735 CFX_ByteString newkey_bytestring = newkey; |
| 736 auto new_it = m_Map.find(newkey_bytestring); | 736 auto new_it = m_Map.find(newkey_bytestring); |
| 737 if (new_it == old_it) |
| 738 return; |
| 739 |
| 737 if (new_it != m_Map.end()) { | 740 if (new_it != m_Map.end()) { |
| 738 new_it->second->Release(); | 741 new_it->second->Release(); |
| 739 new_it->second = old_it->second; | 742 new_it->second = old_it->second; |
| 740 } else { | 743 } else { |
| 741 m_Map.insert(std::make_pair(newkey_bytestring, old_it->second)); | 744 m_Map.insert(std::make_pair(newkey_bytestring, old_it->second)); |
| 742 } | 745 } |
| 743 m_Map.erase(old_it); | 746 m_Map.erase(old_it); |
| 744 } | 747 } |
| 745 FX_BOOL CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const { | 748 FX_BOOL CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const { |
| 746 if (!pOther) { | 749 if (!pOther) { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 pObj->Destroy(); | 1133 pObj->Destroy(); |
| 1131 return FALSE; | 1134 return FALSE; |
| 1132 } | 1135 } |
| 1133 it->second->Destroy(); | 1136 it->second->Destroy(); |
| 1134 } | 1137 } |
| 1135 pObj->m_ObjNum = objnum; | 1138 pObj->m_ObjNum = objnum; |
| 1136 m_IndirectObjs[objnum] = pObj; | 1139 m_IndirectObjs[objnum] = pObj; |
| 1137 m_LastObjNum = std::max(m_LastObjNum, objnum); | 1140 m_LastObjNum = std::max(m_LastObjNum, objnum); |
| 1138 return TRUE; | 1141 return TRUE; |
| 1139 } | 1142 } |
| OLD | NEW |