aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2020-01-28 21:33:26 +0000
committerChromium commit bot <commit-bot@chromium.org>2020-01-28 21:33:26 +0000
commit5c2e173e0585f9b7a798cc1d5bdfd4801e016c65 (patch)
treec992a728d04cc1672cd61c00dbfb51e7ce9d0ea4 /core
parente5e522c140a21560ba6a360fb854017fd33177ec (diff)
downloadpdfium-5c2e173e0585f9b7a798cc1d5bdfd4801e016c65.tar.gz
Change various CMap code to take a ByteStringView.
ByteStringView modifications are cheaper than ByteString modifications. Minimize headers in fpdf_cmaps.* along the way and do IWYU. Change-Id: I3b32faaf81309a5ac2c8e07bc2937c73a11d8b7b Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/65650 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp2
-rw-r--r--core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp2
-rw-r--r--core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp2
-rw-r--r--core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp2
-rw-r--r--core/fpdfapi/cmaps/fpdf_cmaps.cpp4
-rw-r--r--core/fpdfapi/cmaps/fpdf_cmaps.h5
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp3
-rw-r--r--core/fpdfapi/font/cpdf_cmap.cpp7
-rw-r--r--core/fpdfapi/font/cpdf_cmap.h2
-rw-r--r--core/fpdfapi/font/cpdf_cmapmanager.cpp4
10 files changed, 20 insertions, 13 deletions
diff --git a/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp b/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp
index 80c31d629..810104eee 100644
--- a/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp
+++ b/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/cmaps/CNS1/cmaps_cns1.h"
+#include "core/fxcrt/fx_memory.h"
+
const FXCMAP_CMap g_FXCMAP_CNS1_cmaps[] = {
{"B5pc-H", g_FXCMAP_B5pc_H_0, nullptr, 247, 0, FXCMAP_CMap::Range, 0},
{"B5pc-V", g_FXCMAP_B5pc_V_0, nullptr, 12, 0, FXCMAP_CMap::Range, -1},
diff --git a/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp b/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp
index 0ba0db71d..a5980917e 100644
--- a/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp
+++ b/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/cmaps/GB1/cmaps_gb1.h"
+#include "core/fxcrt/fx_memory.h"
+
const FXCMAP_CMap g_FXCMAP_GB1_cmaps[] = {
{"GB-EUC-H", g_FXCMAP_GB_EUC_H_0, nullptr, 90, 0, FXCMAP_CMap::Range, 0},
{"GB-EUC-V", g_FXCMAP_GB_EUC_V_0, nullptr, 20, 0, FXCMAP_CMap::Range, -1},
diff --git a/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp b/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp
index 9b9cfc37a..5a48c771d 100644
--- a/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp
+++ b/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/cmaps/Japan1/cmaps_japan1.h"
+#include "core/fxcrt/fx_memory.h"
+
const FXCMAP_CMap g_FXCMAP_Japan1_cmaps[] = {
{"83pv-RKSJ-H", g_FXCMAP_83pv_RKSJ_H_1, nullptr, 222, 0, FXCMAP_CMap::Range,
0},
diff --git a/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp b/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp
index a95ab3ee3..7362ff859 100644
--- a/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp
+++ b/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/cmaps/Korea1/cmaps_korea1.h"
+#include "core/fxcrt/fx_memory.h"
+
const FXCMAP_CMap g_FXCMAP_Korea1_cmaps[] = {
{"KSC-EUC-H", g_FXCMAP_KSC_EUC_H_0, nullptr, 467, 0, FXCMAP_CMap::Range, 0},
{"KSC-EUC-V", g_FXCMAP_KSC_EUC_V_0, nullptr, 16, 0, FXCMAP_CMap::Range, -1},
diff --git a/core/fpdfapi/cmaps/fpdf_cmaps.cpp b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
index 750c04d28..5c89faf81 100644
--- a/core/fpdfapi/cmaps/fpdf_cmaps.cpp
+++ b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
@@ -8,8 +8,6 @@
#include <algorithm>
-#include "third_party/base/span.h"
-
namespace {
struct SingleCmap {
@@ -30,7 +28,7 @@ const FXCMAP_CMap* FindNextCMap(const FXCMAP_CMap* pMap) {
} // namespace
const FXCMAP_CMap* FindEmbeddedCMap(pdfium::span<const FXCMAP_CMap> pCMaps,
- const ByteString& bsName) {
+ ByteStringView bsName) {
for (size_t i = 0; i < pCMaps.size(); i++) {
if (bsName == pCMaps[i].m_Name)
return &pCMaps[i];
diff --git a/core/fpdfapi/cmaps/fpdf_cmaps.h b/core/fpdfapi/cmaps/fpdf_cmaps.h
index c84dc57a3..2c7548ac9 100644
--- a/core/fpdfapi/cmaps/fpdf_cmaps.h
+++ b/core/fpdfapi/cmaps/fpdf_cmaps.h
@@ -7,8 +7,9 @@
#ifndef CORE_FPDFAPI_CMAPS_FPDF_CMAPS_H_
#define CORE_FPDFAPI_CMAPS_FPDF_CMAPS_H_
+#include <stdint.h>
+
#include "core/fxcrt/fx_string.h"
-#include "core/fxcrt/fx_system.h"
#include "third_party/base/span.h"
struct FXCMAP_DWordCIDMap {
@@ -31,7 +32,7 @@ struct FXCMAP_CMap {
};
const FXCMAP_CMap* FindEmbeddedCMap(pdfium::span<const FXCMAP_CMap> pCMaps,
- const ByteString& name);
+ ByteStringView name);
uint16_t CIDFromCharCode(const FXCMAP_CMap* pMap, uint32_t charcode);
uint32_t CharCodeFromCID(const FXCMAP_CMap* pMap, uint16_t cid);
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 19dbf86fa..0c02b9e19 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -360,7 +360,8 @@ bool CPDF_CIDFont::Load() {
} else if (CPDF_Stream* pStream = pEncoding->AsStream()) {
auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
pAcc->LoadAllDataFiltered();
- m_pCMap = pdfium::MakeRetain<CPDF_CMap>(pAcc->GetSpan());
+ pdfium::span<const uint8_t> span = pAcc->GetSpan();
+ m_pCMap = pdfium::MakeRetain<CPDF_CMap>(span);
} else {
return false;
}
diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp
index 9d1603b2f..844bc5f2a 100644
--- a/core/fpdfapi/font/cpdf_cmap.cpp
+++ b/core/fpdfapi/font/cpdf_cmap.cpp
@@ -181,12 +181,11 @@ constexpr PredefinedCMap kPredefinedCMaps[] = {
{"UniKS-UTF16", CIDSET_KOREA1, CIDCODING_UTF16, CPDF_CMap::TwoBytes, 0, {}},
};
-const PredefinedCMap* GetPredefinedCMap(const ByteString& bsPredefinedName) {
- ByteString cmapid = bsPredefinedName;
+const PredefinedCMap* GetPredefinedCMap(ByteStringView cmapid) {
if (cmapid.GetLength() > 2)
cmapid = cmapid.First(cmapid.GetLength() - 2);
for (const auto& map : kPredefinedCMaps) {
- if (cmapid == ByteStringView(map.m_pName))
+ if (cmapid == map.m_pName)
return &map;
}
return nullptr;
@@ -258,7 +257,7 @@ size_t GetFourByteCharSizeImpl(
} // namespace
-CPDF_CMap::CPDF_CMap(const ByteString& bsPredefinedName)
+CPDF_CMap::CPDF_CMap(ByteStringView bsPredefinedName)
: m_bVertical(bsPredefinedName.Back() == 'V') {
if (bsPredefinedName == "Identity-H" || bsPredefinedName == "Identity-V") {
m_Coding = CIDCODING_CID;
diff --git a/core/fpdfapi/font/cpdf_cmap.h b/core/fpdfapi/font/cpdf_cmap.h
index 6754c71e8..e2caf8d2e 100644
--- a/core/fpdfapi/font/cpdf_cmap.h
+++ b/core/fpdfapi/font/cpdf_cmap.h
@@ -78,7 +78,7 @@ class CPDF_CMap final : public Retainable {
}
private:
- explicit CPDF_CMap(const ByteString& bsPredefinedName);
+ explicit CPDF_CMap(ByteStringView bsPredefinedName);
explicit CPDF_CMap(pdfium::span<const uint8_t> spEmbeddedData);
~CPDF_CMap() override;
diff --git a/core/fpdfapi/font/cpdf_cmapmanager.cpp b/core/fpdfapi/font/cpdf_cmapmanager.cpp
index 412971625..726b6489f 100644
--- a/core/fpdfapi/font/cpdf_cmapmanager.cpp
+++ b/core/fpdfapi/font/cpdf_cmapmanager.cpp
@@ -14,7 +14,7 @@
namespace {
-RetainPtr<const CPDF_CMap> LoadPredefinedCMap(ByteString name) {
+RetainPtr<const CPDF_CMap> LoadPredefinedCMap(ByteStringView name) {
if (!name.IsEmpty() && name[0] == '/')
name = name.Last(name.GetLength() - 1);
return pdfium::MakeRetain<CPDF_CMap>(name);
@@ -32,7 +32,7 @@ RetainPtr<const CPDF_CMap> CPDF_CMapManager::GetPredefinedCMap(
if (it != m_CMaps.end())
return it->second;
- RetainPtr<const CPDF_CMap> pCMap = LoadPredefinedCMap(name);
+ RetainPtr<const CPDF_CMap> pCMap = LoadPredefinedCMap(name.AsStringView());
if (!name.IsEmpty())
m_CMaps[name] = pCMap;