diff options
author | Kirit Sælensminde <k@kirit.com> | 2018-01-12 20:38:56 +0700 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2018-01-12 08:38:56 -0500 |
commit | 59b94d2bbf43440790abd64d953a3c7f576c4ce3 (patch) | |
tree | 4a75ac0e14ea7d1d3a199bd863af0cfff7e909c9 /zdeflate.cpp | |
parent | c6289edd44815a0d42823e8c0f283fc25d7506de (diff) | |
download | cryptopp-git-59b94d2bbf43440790abd64d953a3c7f576c4ce3.tar.gz |
C++17 compatible lambda expressions to replace `bind2nd` (#559)
* Conditionally use a lambda rather than the older `bind2nd` style.
* Duplicate the if statements.
* Centralise the conditional compilation to an implementation of find_if_not.
* Refactoring of name and code placement after review.
* Use `FindIfNot` where appropriate.
* Remove whitespace.
Diffstat (limited to 'zdeflate.cpp')
-rw-r--r-- | zdeflate.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/zdeflate.cpp b/zdeflate.cpp index 24576b9f..fcabe209 100644 --- a/zdeflate.cpp +++ b/zdeflate.cpp @@ -676,11 +676,11 @@ void Deflator::EncodeBlock(bool eof, unsigned int blockType) m_literalCounts[256] = 1;
HuffmanEncoder::GenerateCodeLengths(literalCodeLengths, 15, m_literalCounts, 286);
m_dynamicLiteralEncoder.Initialize(literalCodeLengths, 286);
- unsigned int hlit = (unsigned int)(std::find_if(RevIt(literalCodeLengths.end()), RevIt(literalCodeLengths.begin()+257), std::bind2nd(std::not_equal_to<unsigned int>(), 0)).base() - (literalCodeLengths.begin()+257));
+ unsigned int hlit = (unsigned int)(FindIfNot(RevIt(literalCodeLengths.end()), RevIt(literalCodeLengths.begin()+257), 0).base() - (literalCodeLengths.begin()+257));
HuffmanEncoder::GenerateCodeLengths(distanceCodeLengths, 15, m_distanceCounts, 30);
m_dynamicDistanceEncoder.Initialize(distanceCodeLengths, 30);
- unsigned int hdist = (unsigned int)(std::find_if(RevIt(distanceCodeLengths.end()), RevIt(distanceCodeLengths.begin()+1), std::bind2nd(std::not_equal_to<unsigned int>(), 0)).base() - (distanceCodeLengths.begin()+1));
+ unsigned int hdist = (unsigned int)(FindIfNot(RevIt(distanceCodeLengths.end()), RevIt(distanceCodeLengths.begin()+1), 0).base() - (distanceCodeLengths.begin()+1));
SecBlockWithHint<unsigned int, 286+30> combinedLengths(hlit+257+hdist+1);
memcpy(combinedLengths, literalCodeLengths, (hlit+257)*sizeof(unsigned int));
|