diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-04-23 21:09:33 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-23 21:09:33 +0000 |
commit | 1e95aeadd33fc4a13f5579501f81b6d5edc7cc05 (patch) | |
tree | 3a59f03455222b98d0123bb74fee44f3fb69b328 /fxbarcode/datamatrix/BC_Base256Encoder.cpp | |
parent | 4e4147eccd25e66a5c61712121c30c8d5f2ba56c (diff) | |
download | pdfium-1e95aeadd33fc4a13f5579501f81b6d5edc7cc05.tar.xz |
Pre-allocate more string buffers in barcode code
Another couple of examples where the slow down in the barcode code
can be fixed by reserving and thus pre-allocating the buffer that
backs the Widestring. Doing += in a tight loop caused reallocation
thrashing.
BUG=chromium:834630
Change-Id: I48a802225351bcaf992c324732fddf81639b4898
Reviewed-on: https://pdfium-review.googlesource.com/31230
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fxbarcode/datamatrix/BC_Base256Encoder.cpp')
-rw-r--r-- | fxbarcode/datamatrix/BC_Base256Encoder.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fxbarcode/datamatrix/BC_Base256Encoder.cpp b/fxbarcode/datamatrix/BC_Base256Encoder.cpp index b7dd69c0f7..1010cfe32c 100644 --- a/fxbarcode/datamatrix/BC_Base256Encoder.cpp +++ b/fxbarcode/datamatrix/BC_Base256Encoder.cpp @@ -35,6 +35,7 @@ int32_t CBC_Base256Encoder::getEncodingMode() { } void CBC_Base256Encoder::Encode(CBC_EncoderContext& context, int32_t& e) { WideString buffer; + buffer.Reserve(context.getRemainingCharacters() + 1); buffer += L'\0'; while (context.hasMoreCharacters()) { wchar_t c = context.getCurrentChar(); |