summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-12-22 13:41:54 -0800
committerLei Zhang <thestig@chromium.org>2015-12-22 13:41:54 -0800
commitf6dafc90ec1a0df8d618efc68c0223f0cdd80ffb (patch)
treebea547a227b6223178546c8cc17c6904ebb4ded6 /core/include
parentf84fd2b1dac1fcca41db84d162995c38af650614 (diff)
downloadpdfium-f6dafc90ec1a0df8d618efc68c0223f0cdd80ffb.tar.xz
Convert CPDF_Parser::m_CrossRef to a std::map.
This improvements memory usage in case PDFs have sparse object numbers. The map holds a struct that currently has only one member. The struct will contain more members as other internal data structures get converted. BUG=pdfium:111 R=weili@chromium.org Review URL: https://codereview.chromium.org/1539573003 .
Diffstat (limited to 'core/include')
-rw-r--r--core/include/fpdfapi/fpdf_parser.h35
1 files changed, 14 insertions, 21 deletions
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index de0aa6196c..752df789da 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -394,10 +394,6 @@ class CPDF_Parser {
CFX_ByteString GetPassword() { return m_Password; }
- CPDF_SecurityHandler* GetSecurityHandler() {
- return m_pSecurityHandler.get();
- }
-
CPDF_CryptoHandler* GetCryptoHandler() {
return m_Syntax.m_pCryptoHandler.get();
}
@@ -405,44 +401,31 @@ class CPDF_Parser {
void SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler,
FX_BOOL bForced = FALSE);
- CFX_ByteString GetRecipient() { return m_bsRecipient; }
-
CPDF_Dictionary* GetTrailer() { return m_pTrailer; }
FX_FILESIZE GetLastXRefOffset() { return m_LastXRefOffset; }
CPDF_Document* GetDocument() { return m_pDocument; }
- CFX_ArrayTemplate<CPDF_Dictionary*>* GetOtherTrailers() {
- return &m_Trailers;
- }
-
FX_DWORD GetRootObjNum();
FX_DWORD GetInfoObjNum();
CPDF_Array* GetIDArray();
CPDF_Dictionary* GetEncryptDict() { return m_pEncryptDict; }
- FX_BOOL IsEncrypted() { return GetEncryptDict() != NULL; }
-
CPDF_Object* ParseIndirectObject(CPDF_IndirectObjects* pObjList,
FX_DWORD objnum,
PARSE_CONTEXT* pContext = NULL);
- FX_DWORD GetLastObjNum();
+ FX_DWORD GetLastObjNum() const;
+ bool IsValidObjectNumber(FX_DWORD objnum) const;
FX_BOOL IsFormStream(FX_DWORD objnum, FX_BOOL& bForm);
FX_FILESIZE GetObjectOffset(FX_DWORD objnum);
FX_FILESIZE GetObjectSize(FX_DWORD objnum);
- int GetObjectVersion(FX_DWORD objnum) { return m_ObjVersion[objnum]; }
-
void GetIndirectBinary(FX_DWORD objnum, uint8_t*& pBuffer, FX_DWORD& size);
- FX_BOOL GetFileStreamOption() { return m_Syntax.m_bFileStream; }
-
- void SetFileStreamOption(FX_BOOL b) { m_Syntax.m_bFileStream = b; }
-
IFX_FileRead* GetFileAccess() const { return m_Syntax.m_pFileAccess; }
int GetFileVersion() const { return m_FileVersion; }
@@ -523,13 +506,23 @@ class CPDF_Parser {
CFX_ByteString m_Password;
- CFX_FileSizeArray m_CrossRef;
+ struct ObjectInfo {
+ ObjectInfo() : pos(0) {}
+
+ FX_FILESIZE pos;
+// TODO(thestig): Use fields below in place of |m_V5Type| and |m_ObjVersion|
+#if 0
+ uint8_t type;
+ uint16_t gennum;
+#endif
+ };
+ std::map<FX_DWORD, ObjectInfo> m_ObjectInfo;
CFX_ByteArray m_V5Type;
+ CFX_WordArray m_ObjVersion;
CFX_FileSizeArray m_SortedOffset;
- CFX_WordArray m_ObjVersion;
CFX_ArrayTemplate<CPDF_Dictionary*> m_Trailers;
FX_BOOL m_bVersionUpdated;