diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-04-09 20:33:45 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-09 20:33:45 +0000 |
commit | e372ad7333bdd6bb0c579cf074843ef0c6f3414f (patch) | |
tree | 9928344d0def23d3fb070713a88947aceb6b5c71 /core/fpdfapi/font/cpdf_cmap.cpp | |
parent | 0d8e530fbf898c1ba1ba4d3d91aa17e3fd4d8317 (diff) | |
download | pdfium-e372ad7333bdd6bb0c579cf074843ef0c6f3414f.tar.xz |
Use ByteStringView / pdfium::span in CPDF font as appropriate.chromium/3393
Change-Id: I92c7ba605bf95a9023ad046b8dddebe0a0592802
Reviewed-on: https://pdfium-review.googlesource.com/29992
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/font/cpdf_cmap.cpp')
-rw-r--r-- | core/fpdfapi/font/cpdf_cmap.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp index 81ad63344c..8e46a75112 100644 --- a/core/fpdfapi/font/cpdf_cmap.cpp +++ b/core/fpdfapi/font/cpdf_cmap.cpp @@ -337,10 +337,9 @@ uint16_t CPDF_CMap::CIDFromCharCode(uint32_t charcode) const { return it->m_StartCID + charcode - it->m_StartCode; } -uint32_t CPDF_CMap::GetNextChar(const char* pString, - int nStrLen, - int& offset) const { - auto* pBytes = reinterpret_cast<const uint8_t*>(pString); +uint32_t CPDF_CMap::GetNextChar(const ByteStringView& pString, + size_t& offset) const { + auto pBytes = pString.span(); switch (m_CodingScheme) { case OneByte: { return pBytes[offset++]; @@ -370,7 +369,7 @@ uint32_t CPDF_CMap::GetNextChar(const char* pString, charcode = (charcode << 8) + codes[i]; return charcode; } - if (char_size == 4 || offset == nStrLen) + if (char_size == 4 || offset == pBytes.size()) return 0; codes[char_size++] = pBytes[offset++]; } @@ -402,33 +401,32 @@ int CPDF_CMap::GetCharSize(uint32_t charcode) const { return 1; } -int CPDF_CMap::CountChar(const char* pString, int size) const { +size_t CPDF_CMap::CountChar(const ByteStringView& pString) const { switch (m_CodingScheme) { case OneByte: - return size; + return pString.GetLength(); case TwoBytes: - return (size + 1) / 2; + return (pString.GetLength() + 1) / 2; case MixedTwoBytes: { - int count = 0; - for (int i = 0; i < size; i++) { + size_t count = 0; + for (size_t i = 0; i < pString.GetLength(); i++) { count++; - if (m_MixedTwoByteLeadingBytes[reinterpret_cast<const uint8_t*>( - pString)[i]]) { + if (m_MixedTwoByteLeadingBytes[pString[i]]) i++; - } } return count; } case MixedFourBytes: { - int count = 0, offset = 0; - while (offset < size) { - GetNextChar(pString, size, offset); + size_t count = 0; + size_t offset = 0; + while (offset < pString.GetLength()) { + GetNextChar(pString, offset); count++; } return count; } } - return size; + return pString.GetLength(); } int CPDF_CMap::AppendChar(char* str, uint32_t charcode) const { |