From 785da23f6cce8004b8e7759345abd877dab953ea Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 26 Jun 2018 17:20:28 +0000 Subject: Use pdfium::span in CPDF_CID2UnicodeMap. Change-Id: Ie63f622674d9085fa45642c15e7ee8b22ca98555 Reviewed-on: https://pdfium-review.googlesource.com/36130 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- core/fpdfapi/font/cpdf_cidfont.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'core/fpdfapi/font/cpdf_cidfont.cpp') diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 4b4f04ba5f..ef471d02f1 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -23,6 +23,7 @@ #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "third_party/base/numerics/safe_math.h" #include "third_party/base/ptr_util.h" +#include "third_party/base/span.h" #include "third_party/base/stl_util.h" namespace { @@ -150,12 +151,9 @@ wchar_t EmbeddedUnicodeFromCharcode(const FXCMAP_CMap* pEmbedMap, if (!cid) return 0; - const uint16_t* map; - uint32_t count; - std::tie(count, map) = GetFontGlobals()->GetEmbeddedToUnicode(charset); - if (map && cid < count) - return map[cid]; - return 0; + pdfium::span map = + GetFontGlobals()->GetEmbeddedToUnicode(charset); + return cid < map.size() ? map[cid] : 0; } uint32_t EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, @@ -164,13 +162,9 @@ uint32_t EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset)) return 0; - const uint16_t* map; - uint32_t count; - std::tie(count, map) = GetFontGlobals()->GetEmbeddedToUnicode(charset); - if (!map) - return 0; - - for (uint32_t i = 0; i < count; ++i) { + pdfium::span map = + GetFontGlobals()->GetEmbeddedToUnicode(charset); + for (uint32_t i = 0; i < map.size(); ++i) { if (map[i] == unicode) { uint32_t charCode = FPDFAPI_CharCodeFromCID(pEmbedMap, i); if (charCode) -- cgit v1.2.3