diff options
author | lloyd <[email protected]> | 2013-08-25 14:41:14 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2013-08-25 14:41:14 +0000 |
commit | 6370d7e3498fee1e3a60a30b58c4fa25591f4dde (patch) | |
tree | 5d75a2feee59406236a2a4eea8e34df134ebc6b4 | |
parent | 010ef001d56011078f629cd03e59809068cb3be4 (diff) |
Preallocate buffer in Transformation_Filter
-rw-r--r-- | src/filters/transform_filter.cpp | 9 | ||||
-rw-r--r-- | src/filters/transform_filter.h | 1 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/filters/transform_filter.cpp b/src/filters/transform_filter.cpp index 20fbec72a..22f40143f 100644 --- a/src/filters/transform_filter.cpp +++ b/src/filters/transform_filter.cpp @@ -15,6 +15,7 @@ Transformation_Filter::Transformation_Filter(Transformation* transform) : Buffered_Filter(transform->update_granularity(), transform->minimum_final_size()), m_nonce(transform->default_nonce_size() == 0), + m_buffer(transform->update_granularity()), m_transform(transform) { } @@ -77,16 +78,14 @@ void Transformation_Filter::start_msg() void Transformation_Filter::buffered_block(const byte input[], size_t input_length) { - secure_vector<byte> buf; - while(input_length) { const size_t take = std::min(m_transform->update_granularity(), input_length); - buf.assign(input, input + take); - m_transform->update(buf); + m_buffer.assign(input, input + take); + m_transform->update(m_buffer); - send(buf); + send(m_buffer); input += take; input_length -= take; diff --git a/src/filters/transform_filter.h b/src/filters/transform_filter.h index 7cbc2eccb..c7033a060 100644 --- a/src/filters/transform_filter.h +++ b/src/filters/transform_filter.h @@ -61,6 +61,7 @@ class BOTAN_DLL Transformation_Filter : public Keyed_Filter, Nonce_State m_nonce; std::unique_ptr<Transformation> m_transform; + secure_vector<byte> m_buffer; }; } |