From e372ad7333bdd6bb0c579cf074843ef0c6f3414f Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 9 Apr 2018 20:33:45 +0000 Subject: Use ByteStringView / pdfium::span in CPDF font as appropriate. Change-Id: I92c7ba605bf95a9023ad046b8dddebe0a0592802 Reviewed-on: https://pdfium-review.googlesource.com/29992 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- core/fpdfapi/page/cpdf_textobject.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index 402bf2ef66..36a4722773 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -152,18 +152,17 @@ void CPDF_TextObject::SetSegments(const ByteString* pStrs, CPDF_Font* pFont = m_TextState.GetFont(); int nChars = 0; for (int i = 0; i < nsegs; ++i) - nChars += pFont->CountChar(pStrs[i].c_str(), pStrs[i].GetLength()); + nChars += pFont->CountChar(pStrs[i].AsStringView()); nChars += nsegs - 1; m_CharCodes.resize(nChars); m_CharPos.resize(nChars - 1); - int index = 0; + size_t index = 0; for (int i = 0; i < nsegs; ++i) { - const char* segment = pStrs[i].c_str(); - int len = pStrs[i].GetLength(); - int offset = 0; - while (offset < len) { - ASSERT(static_cast(index) < m_CharCodes.size()); - m_CharCodes[index++] = pFont->GetNextChar(segment, len, offset); + ByteStringView segment = pStrs[i].AsStringView(); + size_t offset = 0; + while (offset < segment.GetLength()) { + ASSERT(index < m_CharCodes.size()); + m_CharCodes[index++] = pFont->GetNextChar(segment, offset); } if (i != nsegs - 1) { m_CharPos[index - 1] = pKerning[i]; -- cgit v1.2.3