diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-05-25 20:12:39 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-25 20:12:39 +0000 |
commit | d4d645abecec0fe2e6477b5928cfa2967675585b (patch) | |
tree | a130cf0a76265c359e4fd1331213c836fe7066e7 | |
parent | 710fa99b0bd26e6761c4481b4b9b6d26d2954c3e (diff) | |
download | pdfium-d4d645abecec0fe2e6477b5928cfa2967675585b.tar.xz |
Reserve space for code words when creating encoder context
During encoding, the code is going to walk through every character in
m_msg and determine what values need to be added to m_codewords. The
ceiling on the number of characters being added to m_codewords is the
length of m_msg, so reserving enought space in advance. This prevents
thrash related to incrementing the string and thus resizing in a tight
loop.
BUG=chromium:846027
Change-Id: Icefd6955933f8068feeeee6243e430f60c50d747
Reviewed-on: https://pdfium-review.googlesource.com/32990
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
-rw-r--r-- | fxbarcode/datamatrix/BC_EncoderContext.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.cpp b/fxbarcode/datamatrix/BC_EncoderContext.cpp index d9823bffe2..f5c2f4c1fc 100644 --- a/fxbarcode/datamatrix/BC_EncoderContext.cpp +++ b/fxbarcode/datamatrix/BC_EncoderContext.cpp @@ -44,6 +44,7 @@ CBC_EncoderContext::CBC_EncoderContext(const WideString& msg, sb += ch; } m_msg = sb; + m_codewords.Reserve(m_msg.GetLength()); m_allowRectangular = true; m_newEncoding = -1; m_pos = 0; |