diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-07-28 14:07:04 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-28 18:21:44 +0000 |
commit | e7a99de4f711302d57fe22682a9a8c3cfddb458c (patch) | |
tree | 7bb176d42e2a2181f014b41bd621d6b242ed20e7 /fxbarcode/oned | |
parent | 106eecd27f346a0bc7f11f29a058a8fd16a77682 (diff) | |
download | pdfium-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 'fxbarcode/oned')
-rw-r--r-- | fxbarcode/oned/BC_OnedEAN13Writer.cpp | 4 | ||||
-rw-r--r-- | fxbarcode/oned/BC_OnedEAN8Writer.cpp | 2 | ||||
-rw-r--r-- | fxbarcode/oned/BC_OnedUPCAWriter.cpp | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp index 0e4bab9518..6f1d957a01 100644 --- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp @@ -109,7 +109,7 @@ uint8_t* CBC_OnedEAN13Writer::EncodeImpl(const CFX_ByteString& contents, return nullptr; m_iDataLenth = 13; - int32_t firstDigit = FXSYS_atoi(contents.Mid(0, 1).c_str()); + int32_t firstDigit = FXSYS_atoi(contents.Left(1).c_str()); int32_t parities = FIRST_DIGIT_ENCODINGS[firstDigit]; outLength = m_codeWidth; std::unique_ptr<uint8_t, FxFreeDeleter> result( @@ -219,7 +219,7 @@ bool CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents, static_cast<float>(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } - tempStr = str.Mid(0, 1); + tempStr = str.Left(1); iLen = tempStr.GetLength(); strWidth = multiple * 7; strWidth = (int32_t)(strWidth * m_outputHScale); diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp index f891c08fc6..9a85f814a7 100644 --- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp +++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp @@ -159,7 +159,7 @@ bool CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents, CFX_ByteString str = FX_UTF8Encode(contents); int32_t iLength = str.GetLength(); std::vector<FXTEXT_CHARPOS> charpos(iLength); - CFX_ByteString tempStr = str.Mid(0, 4); + CFX_ByteString tempStr = str.Left(4); int32_t iLen = tempStr.GetLength(); int32_t strWidth = 7 * multiple * 4; float blank = 0.0; diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp index 78ada1783a..13514eb53f 100644 --- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp +++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp @@ -183,7 +183,7 @@ bool CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, static_cast<float>(iFontSize), &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } - tempStr = str.Mid(0, 1); + tempStr = str.Left(1); iLen = tempStr.GetLength(); strWidth = (float)multiple * 7; strWidth = strWidth * m_outputHScale; |