From e7a99de4f711302d57fe22682a9a8c3cfddb458c Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 28 Jul 2017 14:07:04 -0400 Subject: 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 Reviewed-by: Tom Sepez --- core/fxge/cfx_fontmapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/fxge') diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp index 5c7b602fed..4c0073ab73 100644 --- a/core/fxge/cfx_fontmapper.cpp +++ b/core/fxge/cfx_fontmapper.cpp @@ -432,7 +432,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, CFX_ByteString SubstName = name; SubstName.Remove(' '); if (bTrueType && name[0] == '@') - SubstName = name.Mid(1, name.GetLength() - 1); + SubstName = name.Right(name.GetLength() - 1); PDF_GetStandardFontName(&SubstName); if (SubstName == "Symbol" && !bTrueType) { pSubstFont->m_Family = "Chrome Symbol"; @@ -453,7 +453,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (find >= 0) { family = SubstName.Left(find); PDF_GetStandardFontName(&family); - style = SubstName.Mid(find + 1, SubstName.GetLength() - (find + 1)); + style = SubstName.Right(SubstName.GetLength() - (find + 1)); bHasComma = true; } else { family = SubstName; @@ -480,7 +480,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (!bHasComma) { find = family.ReverseFind('-'); if (find >= 0) { - style = family.Mid(find + 1, family.GetLength() - (find + 1)); + style = family.Right(family.GetLength() - (find + 1)); family = family.Left(find); bHasHyphen = true; } -- cgit v1.2.3