diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-08-15 10:37:59 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-15 15:03:10 +0000 |
commit | 8a1758bf11c2d741e0cddc761b1dd2cdf564db93 (patch) | |
tree | 82cbafc46f574a05ae0c1d1d3d7f9ebde6cb932d /fxbarcode/datamatrix/BC_Base256Encoder.cpp | |
parent | 171cb27a720036c48ae3a6176084e880742af0a9 (diff) | |
download | pdfium-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/datamatrix/BC_Base256Encoder.cpp')
-rw-r--r-- | fxbarcode/datamatrix/BC_Base256Encoder.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/fxbarcode/datamatrix/BC_Base256Encoder.cpp index edcd411114..0cbd3fdb10 100644 --- a/fxbarcode/datamatrix/BC_Base256Encoder.cpp +++ b/fxbarcode/datamatrix/BC_Base256Encoder.cpp @@ -35,7 +35,7 @@ int32_t CBC_Base256Encoder::getEncodingMode() { } void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { CFX_WideString buffer; - buffer += (wchar_t)'\0'; + buffer += L'\0'; while (context.hasMoreCharacters()) { wchar_t c = context.getCurrentChar(); buffer += c; @@ -50,7 +50,7 @@ void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { int32_t dataCount = buffer.GetLength() - 1; char buf[128]; FXSYS_itoa(dataCount, buf, 10); - buffer.SetAt(0, wchar_t(*buf) - '0'); + buffer.SetAt(0, static_cast<wchar_t>(*buf) - '0'); int32_t lengthFieldSize = 1; int32_t currentSize = context.getCodewordCount() + dataCount + lengthFieldSize; @@ -61,10 +61,10 @@ void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { bool mustPad = (context.m_symbolInfo->dataCapacity() - currentSize) > 0; if (context.hasMoreCharacters() || mustPad) { if (dataCount <= 249) { - buffer.SetAt(0, (wchar_t)dataCount); + buffer.SetAt(0, static_cast<wchar_t>(dataCount)); } else if (dataCount > 249 && dataCount <= 1555) { - buffer.SetAt(0, (wchar_t)((dataCount / 250) + 249)); - buffer.Insert(1, (wchar_t)(dataCount % 250)); + buffer.SetAt(0, static_cast<wchar_t>((dataCount / 250) + 249)); + buffer.Insert(1, static_cast<wchar_t>(dataCount % 250)); } else { e = BCExceptionIllegalStateMessageLengthInvalid; return; @@ -79,8 +79,8 @@ wchar_t CBC_Base256Encoder::randomize255State(wchar_t ch, int32_t pseudoRandom = ((149 * codewordPosition) % 255) + 1; int32_t tempVariable = ch + pseudoRandom; if (tempVariable <= 255) { - return (wchar_t)tempVariable; + return static_cast<wchar_t>(tempVariable); } else { - return (wchar_t)(tempVariable - 256); + return static_cast<wchar_t>(tempVariable - 256); } } |