summaryrefslogtreecommitdiff
path: root/fxbarcode/datamatrix
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 /fxbarcode/datamatrix
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 'fxbarcode/datamatrix')
-rw-r--r--fxbarcode/datamatrix/BC_HighLevelEncoder.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index ec527d29a8..6034173ee4 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -76,13 +76,12 @@ CFX_WideString CBC_HighLevelEncoder::encodeHighLevel(CFX_WideString msg,
return CFX_WideString();
context.setAllowRectangular(allowRectangular);
- if ((msg.Mid(0, 6) == MACRO_05_HEADER) &&
- (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) {
+ if ((msg.Left(6) == MACRO_05_HEADER) && (msg.Right(1) == MACRO_TRAILER)) {
context.writeCodeword(MACRO_05);
context.setSkipAtEnd(2);
context.m_pos += 6;
- } else if ((msg.Mid(0, 6) == MACRO_06_HEADER) &&
- (msg.Mid(msg.GetLength() - 1, 1) == MACRO_TRAILER)) {
+ } else if ((msg.Left(6) == MACRO_06_HEADER) &&
+ (msg.Right(1) == MACRO_TRAILER)) {
context.writeCodeword(MACRO_06);
context.setSkipAtEnd(2);
context.m_pos += 6;