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

Side by Side Diff: core/include/fxcrt/fx_basic.h

Issue 1297723002: CFX_MapByteStringToPtr considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Separate reload & delete. 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 unified diff | Download patch
« no previous file with comments | « no previous file | core/include/fxge/fx_font.h » ('j') | core/src/fpdfapi/fpdf_font/font_int.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CORE_INCLUDE_FXCRT_FX_BASIC_H_ 7 #ifndef CORE_INCLUDE_FXCRT_FX_BASIC_H_
8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_ 8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_
9 9
10 #include "fx_memory.h" 10 #include "fx_memory.h"
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 659
660 void EstimateSize(FX_DWORD size, FX_DWORD grow_by); 660 void EstimateSize(FX_DWORD size, FX_DWORD grow_by);
661 661
662 FX_POSITION GetStartPosition() const; 662 FX_POSITION GetStartPosition() const;
663 663
664 void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const; 664 void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const;
665 665
666 protected: 666 protected:
667 CFX_BinaryBuf m_Buffer; 667 CFX_BinaryBuf m_Buffer;
668 }; 668 };
669 class CFX_MapByteStringToPtr {
670 protected:
671 struct CAssoc {
672 CAssoc* pNext;
673
674 FX_DWORD nHashValue;
675
676 CFX_ByteString key;
677
678 void* value;
679 };
680
681 public:
682 CFX_MapByteStringToPtr(int nBlockSize = 10);
683
684 int GetCount() const { return m_nCount; }
685
686 FX_BOOL IsEmpty() const { return m_nCount == 0; }
687
688 FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const;
689
690 void*& operator[](const CFX_ByteStringC& key);
691
692 void SetAt(const CFX_ByteStringC& key, void* newValue) {
693 (*this)[key] = newValue;
694 }
695
696 FX_BOOL RemoveKey(const CFX_ByteStringC& key);
697
698 void RemoveAll();
699
700 FX_POSITION GetStartPosition() const {
701 return (m_nCount == 0) ? NULL : (FX_POSITION)-1;
702 }
703
704 void GetNextAssoc(FX_POSITION& rNextPosition,
705 CFX_ByteString& rKey,
706 void*& rValue) const;
707
708 void* GetNextValue(FX_POSITION& rNextPosition) const;
709
710 FX_DWORD GetHashTableSize() const { return m_nHashTableSize; }
711
712 void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
713
714 FX_DWORD HashKey(const CFX_ByteStringC& key) const;
715
716 protected:
717 CAssoc** m_pHashTable;
718
719 FX_DWORD m_nHashTableSize;
720
721 int m_nCount;
722
723 CAssoc* m_pFreeList;
724
725 struct CFX_Plex* m_pBlocks;
726
727 int m_nBlockSize;
728
729 CAssoc* NewAssoc();
730
731 void FreeAssoc(CAssoc* pAssoc);
732
733 CAssoc* GetAssocAt(const CFX_ByteStringC& key, FX_DWORD& hash) const;
734
735 public:
736 ~CFX_MapByteStringToPtr();
737 };
738 class CFX_CMapByteStringToPtr { 669 class CFX_CMapByteStringToPtr {
739 public: 670 public:
740 CFX_CMapByteStringToPtr(); 671 CFX_CMapByteStringToPtr();
741 672
742 ~CFX_CMapByteStringToPtr(); 673 ~CFX_CMapByteStringToPtr();
743 674
744 void RemoveAll(); 675 void RemoveAll();
745 676
746 FX_POSITION GetStartPosition() const; 677 FX_POSITION GetStartPosition() const;
747 678
748 void GetNextAssoc(FX_POSITION& rNextPosition, 679 void GetNextAssoc(FX_POSITION& rNextPosition,
749 CFX_ByteString& rKey, 680 CFX_ByteString& rKey,
750 void*& rValue) const; 681 void*& rValue) const;
751 682
752 void* GetNextValue(FX_POSITION& rNextPosition) const; 683 void* GetNextValue(FX_POSITION& rNextPosition) const;
753 684
754 FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const; 685 FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const;
755 686
756 void SetAt(const CFX_ByteStringC& key, void* value); 687 void SetAt(const CFX_ByteStringC& key, void* value);
757 688
758 void RemoveKey(const CFX_ByteStringC& key); 689 void RemoveKey(const CFX_ByteStringC& key);
759 690
760 int GetCount() const; 691 int GetCount() const;
761 692
762 void AddValue(const CFX_ByteStringC& key, void* pValue); 693 void AddValue(const CFX_ByteStringC& key, void* pValue);
Lei Zhang 2015/08/15 00:47:33 BTW, this is the trickier map class.
Tom Sepez 2015/08/17 20:15:25 Yup. It ripples through Dictionary objects.
763 694
764 private: 695 private:
765 CFX_BaseSegmentedArray m_Buffer; 696 CFX_BaseSegmentedArray m_Buffer;
766 }; 697 };
767 class CFX_PtrList { 698 class CFX_PtrList {
768 protected: 699 protected:
769 struct CNode { 700 struct CNode {
770 CNode* pNext; 701 CNode* pNext;
771 702
772 CNode* pPrev; 703 CNode* pPrev;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 FX_FLOAT c; 1172 FX_FLOAT c;
1242 FX_FLOAT d; 1173 FX_FLOAT d;
1243 FX_FLOAT e; 1174 FX_FLOAT e;
1244 FX_FLOAT f; 1175 FX_FLOAT f;
1245 FX_FLOAT g; 1176 FX_FLOAT g;
1246 FX_FLOAT h; 1177 FX_FLOAT h;
1247 FX_FLOAT i; 1178 FX_FLOAT i;
1248 }; 1179 };
1249 1180
1250 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ 1181 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_
OLDNEW
« no previous file with comments | « no previous file | core/include/fxge/fx_font.h » ('j') | core/src/fpdfapi/fpdf_font/font_int.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698