summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-07-28 14:07:04 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-28 18:21:44 +0000
commite7a99de4f711302d57fe22682a9a8c3cfddb458c (patch)
tree7bb176d42e2a2181f014b41bd621d6b242ed20e7 /core/fpdfapi
parent106eecd27f346a0bc7f11f29a058a8fd16a77682 (diff)
downloadpdfium-e7a99de4f711302d57fe22682a9a8c3cfddb458c.tar.xz
Convert calls to Mid() to Left() or Right() if possible
The various string/byte classes support Mid(), Left(), and Right() for extracting substrings. Mid() can handle all possible cases, but Left() and Right() are useful for common cases and more explicit about what is going on. Calls like Mid(offset, length - offset) can be converted to Right(length - offset). Calls like Mid(0, length) can be converted to Left(length). If the substring being extracted does not extend all the way to one of the edges of the string, then Mid() still needs to be used. BUG=pdfium:828 Change-Id: I2ec46ad3d71aac0f7b513e103c69cbe8c854cf62 Reviewed-on: https://pdfium-review.googlesource.com/9510 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index 8c8520f0c4..56a4b13cb3 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -130,7 +130,7 @@ bool CPDF_SimpleFont::LoadCommon() {
}
if (m_pFontFile) {
if (m_BaseFont.GetLength() > 8 && m_BaseFont[7] == '+')
- m_BaseFont = m_BaseFont.Mid(8, m_BaseFont.GetLength() - 8);
+ m_BaseFont = m_BaseFont.Right(m_BaseFont.GetLength() - 8);
} else {
LoadSubstFont();
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 5f571aa8d6..288f9d57a8 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -620,7 +620,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
break;
}
auto word = m_pSyntax->GetWord();
- CFX_ByteString key(word.Mid(1, word.GetLength() - 1));
+ CFX_ByteString key(word.Right(word.GetLength() - 1));
auto pObj = m_pSyntax->ReadNextObject(false, false, 0);
if (!key.IsEmpty()) {
uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
@@ -1186,7 +1186,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
}
if (name == "DeviceGray" || name == "DeviceCMYK" || name == "DeviceRGB") {
CFX_ByteString defname = "Default";
- defname += name.Mid(7, name.GetLength() - 7);
+ defname += name.Right(name.GetLength() - 7);
CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname);
if (!pDefObj) {
if (name == "DeviceGray") {
@@ -1525,7 +1525,7 @@ uint32_t CPDF_StreamContentParser::Parse(const uint8_t* pData,
break;
case CPDF_StreamParser::Name: {
auto word = syntax.GetWord();
- AddNameParam(word.Mid(1, word.GetLength() - 1));
+ AddNameParam(word.Right(word.GetLength() - 1));
break;
}
default: