summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp
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/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp
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/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp')
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp
index d3187c1ff4..3fd8dcf35a 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp
@@ -267,7 +267,8 @@ TEST(fpdf_parser_parser, RebuildCrossRefCorrectly) {
ASSERT_TRUE(parser.RebuildCrossRef());
const FX_FILESIZE offsets[] = {0, 15, 61, 154, 296, 374, 450};
const FX_WORD versions[] = {0, 0, 2, 4, 6, 8, 0};
- ASSERT_TRUE(CompareArray(parser.m_CrossRef, offsets, FX_ArraySize(offsets)));
+ for (size_t i = 0; i < FX_ArraySize(offsets); ++i)
+ EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
ASSERT_TRUE(
CompareArray(parser.m_ObjVersion, versions, FX_ArraySize(versions)));
}
@@ -301,8 +302,8 @@ TEST(fpdf_parser_parser, LoadCrossRefV4) {
ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
const FX_FILESIZE offsets[] = {0, 17, 81, 0, 331, 409};
const uint8_t types[] = {0, 1, 1, 0, 1, 1};
- ASSERT_TRUE(
- CompareArray(parser.m_CrossRef, offsets, FX_ArraySize(offsets)));
+ for (size_t i = 0; i < FX_ArraySize(offsets); ++i)
+ EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
ASSERT_TRUE(CompareArray(parser.m_V5Type, types, FX_ArraySize(types)));
}
{
@@ -326,8 +327,8 @@ TEST(fpdf_parser_parser, LoadCrossRefV4) {
const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0,
0, 25518, 25635, 0, 0, 25777};
const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1};
- ASSERT_TRUE(
- CompareArray(parser.m_CrossRef, offsets, FX_ArraySize(offsets)));
+ for (size_t i = 0; i < FX_ArraySize(offsets); ++i)
+ EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
ASSERT_TRUE(CompareArray(parser.m_V5Type, types, FX_ArraySize(types)));
}
{
@@ -351,8 +352,8 @@ TEST(fpdf_parser_parser, LoadCrossRefV4) {
const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0,
0, 0, 25635, 0, 0, 25777};
const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1};
- ASSERT_TRUE(
- CompareArray(parser.m_CrossRef, offsets, FX_ArraySize(offsets)));
+ for (size_t i = 0; i < FX_ArraySize(offsets); ++i)
+ EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
ASSERT_TRUE(CompareArray(parser.m_V5Type, types, FX_ArraySize(types)));
}
{
@@ -374,8 +375,8 @@ TEST(fpdf_parser_parser, LoadCrossRefV4) {
ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179};
const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1};
- ASSERT_TRUE(
- CompareArray(parser.m_CrossRef, offsets, FX_ArraySize(offsets)));
+ for (size_t i = 0; i < FX_ArraySize(offsets); ++i)
+ EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
ASSERT_TRUE(CompareArray(parser.m_V5Type, types, FX_ArraySize(types)));
}
}