summaryrefslogtreecommitdiff
path: root/fxbarcode/pdf417
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-08-15 10:37:59 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-15 15:03:10 +0000
commit8a1758bf11c2d741e0cddc761b1dd2cdf564db93 (patch)
tree82cbafc46f574a05ae0c1d1d3d7f9ebde6cb932d /fxbarcode/pdf417
parent171cb27a720036c48ae3a6176084e880742af0a9 (diff)
downloadpdfium-8a1758bf11c2d741e0cddc761b1dd2cdf564db93.tar.xz
Remove GetAt from string classes
This method duplicates the behaviour of the const [] operator and doesn't offer any additional safety. Folding them into one implementation. SetAt is retained, since implementing the non-const [] operator to replace SetAt has potential performance concerns. Specifically many non-obvious cases of reading an element using [] will cause a realloc & copy. BUG=pdfium:860 Change-Id: I3ef5e5e5a15376f040256b646eb0d90636e24b67 Reviewed-on: https://pdfium-review.googlesource.com/10870 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxbarcode/pdf417')
-rw-r--r--fxbarcode/pdf417/BC_PDF417.cpp2
-rw-r--r--fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp2
-rw-r--r--fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp32
3 files changed, 18 insertions, 18 deletions
diff --git a/fxbarcode/pdf417/BC_PDF417.cpp b/fxbarcode/pdf417/BC_PDF417.cpp
index 9844798b24..3f492f9c10 100644
--- a/fxbarcode/pdf417/BC_PDF417.cpp
+++ b/fxbarcode/pdf417/BC_PDF417.cpp
@@ -523,7 +523,7 @@ void CBC_PDF417::encodeLowLevel(CFX_WideString fullCodewords,
int32_t pattern = CODEWORD_TABLE[cluster][left];
encodeChar(pattern, 17, logic->getCurrentRow());
for (int32_t x = 0; x < c; x++) {
- pattern = CODEWORD_TABLE[cluster][fullCodewords.GetAt(idx)];
+ pattern = CODEWORD_TABLE[cluster][fullCodewords[idx]];
encodeChar(pattern, 17, logic->getCurrentRow());
idx++;
}
diff --git a/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
index 6f1d7946eb..1d8258e720 100644
--- a/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
+++ b/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
@@ -145,7 +145,7 @@ bool CBC_PDF417ErrorCorrection::generateErrorCorrection(
std::vector<wchar_t> ech(k);
int32_t sld = dataCodewords.GetLength();
for (int32_t i = 0; i < sld; i++) {
- int32_t t1 = (dataCodewords.GetAt(i) + ech[k - 1]) % 929;
+ int32_t t1 = (dataCodewords[i] + ech[k - 1]) % 929;
int32_t t2;
int32_t t3;
for (int32_t j = k - 1; j >= 1; j--) {
diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
index f65cfe46ae..c531716e4f 100644
--- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
+++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.cpp
@@ -64,8 +64,8 @@ CFX_WideString CBC_PDF417HighLevelEncoder::encodeHighLevel(
CFX_WideString msg;
int32_t len = bytes.GetLength();
for (int32_t i = 0; i < len; i++) {
- wchar_t ch = (wchar_t)(bytes.GetAt(i) & 0xff);
- if (ch == '?' && bytes.GetAt(i) != '?') {
+ wchar_t ch = (wchar_t)(bytes[i] & 0xff);
+ if (ch == '?' && bytes[i] != '?') {
e = BCExceptionCharactersOutsideISO88591Encoding;
return CFX_WideString();
}
@@ -154,7 +154,7 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg,
int32_t submode = initialSubmode;
int32_t idx = 0;
while (true) {
- wchar_t ch = msg.GetAt(startpos + idx);
+ wchar_t ch = msg[startpos + idx];
switch (submode) {
case SUBMODE_ALPHA:
if (isAlphaUpper(ch)) {
@@ -216,7 +216,7 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg,
continue;
} else {
if (startpos + idx + 1 < count) {
- wchar_t next = msg.GetAt(startpos + idx + 1);
+ wchar_t next = msg[startpos + idx + 1];
if (isPunctuation(next)) {
submode = SUBMODE_PUNCTUATION;
tmp += (wchar_t)25;
@@ -247,10 +247,10 @@ int32_t CBC_PDF417HighLevelEncoder::encodeText(CFX_WideString msg,
for (int32_t i = 0; i < len; i++) {
bool odd = (i % 2) != 0;
if (odd) {
- h = (wchar_t)((h * 30) + tmp.GetAt(i));
+ h = (wchar_t)((h * 30) + tmp[i]);
sb += h;
} else {
- h = tmp.GetAt(i);
+ h = tmp[i];
}
}
if ((len % 2) != 0) {
@@ -313,7 +313,7 @@ void CBC_PDF417HighLevelEncoder::encodeNumeric(CFX_WideString msg,
bigint = bigint / num900;
} while (!bigint.isZero());
for (int32_t i = tmp.GetLength() - 1; i >= 0; i--) {
- sb += tmp.GetAt(i);
+ sb += tmp[i];
}
idx += len;
}
@@ -343,12 +343,12 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveDigitCount(
int32_t len = msg.GetLength();
int32_t idx = startpos;
if (idx < len) {
- wchar_t ch = msg.GetAt(idx);
+ wchar_t ch = msg[idx];
while (isDigit(ch) && idx < len) {
count++;
idx++;
if (idx < len) {
- ch = msg.GetAt(idx);
+ ch = msg[idx];
}
}
}
@@ -360,13 +360,13 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(
int32_t len = msg.GetLength();
int32_t idx = startpos;
while (idx < len) {
- wchar_t ch = msg.GetAt(idx);
+ wchar_t ch = msg[idx];
int32_t numericCount = 0;
while (numericCount < 13 && isDigit(ch) && idx < len) {
numericCount++;
idx++;
if (idx < len) {
- ch = msg.GetAt(idx);
+ ch = msg[idx];
}
}
if (numericCount >= 13) {
@@ -375,7 +375,7 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveTextCount(
if (numericCount > 0) {
continue;
}
- ch = msg.GetAt(idx);
+ ch = msg[idx];
if (!isText(ch)) {
break;
}
@@ -391,7 +391,7 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount(
int32_t len = msg.GetLength();
int32_t idx = startpos;
while (idx < len) {
- wchar_t ch = msg.GetAt(idx);
+ wchar_t ch = msg[idx];
int32_t numericCount = 0;
while (numericCount < 13 && isDigit(ch)) {
numericCount++;
@@ -399,7 +399,7 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount(
if (i >= len) {
break;
}
- ch = msg.GetAt(i);
+ ch = msg[i];
}
if (numericCount >= 13) {
return idx - startpos;
@@ -411,12 +411,12 @@ int32_t CBC_PDF417HighLevelEncoder::determineConsecutiveBinaryCount(
if (i >= len) {
break;
}
- ch = msg.GetAt(i);
+ ch = msg[i];
}
if (textCount >= 5) {
return idx - startpos;
}
- ch = msg.GetAt(idx);
+ ch = msg[idx];
if ((*bytes)[idx] == 63 && ch != '?') {
e = BCExceptionNonEncodableCharacterDetected;
return -1;