diff --git a/coding/arithmetic_codec.cpp b/coding/arithmetic_codec.cpp index 69f63f3331..d179540b9e 100644 --- a/coding/arithmetic_codec.cpp +++ b/coding/arithmetic_codec.cpp @@ -6,8 +6,6 @@ #include "../base/assert.hpp" #include "../base/bits.hpp" -#include "../std/limits.hpp" - vector FreqsToDistrTable(vector const & origFreqs) { uint64_t freqLowerBound = 0; @@ -21,10 +19,8 @@ vector FreqsToDistrTable(vector const & origFreqs) for (uint32_t i = 0; i < origFreqs.size(); ++i) { uint32_t freq = origFreqs[i]; - if (freq > 0 && freq < minFreq) - minFreq = freq; - if (freq > 0 && freq < freqLowerBound) - freq = static_cast(freqLowerBound); + if (freq > 0 && freq < minFreq) minFreq = freq; + if (freq > 0 && freq < freqLowerBound) freq = freqLowerBound; freqs.push_back(freq); sum += freq; result.push_back(sum); @@ -93,8 +89,7 @@ vector ArithmeticEncoder::Finalize() void ArithmeticEncoder::PropagateCarry() { - ASSERT(m_output.size() > 0, ()); - int i = static_cast(m_output.size() - 1); + int i = m_output.size() - 1; while (i >= 0 && m_output[i] == 0xFF) { m_output[i] = 0; @@ -117,8 +112,7 @@ ArithmeticDecoder::ArithmeticDecoder(Reader & reader, vector const & d uint32_t ArithmeticDecoder::Decode() { - ASSERT(m_distrTable.size() <= numeric_limits::max(), ()); - uint32_t l = 0, r = static_cast(m_distrTable.size()), m = 0; + uint32_t l = 0, r = m_distrTable.size(), m = 0; uint32_t shiftedSize = m_size >> DISTR_SHIFT; while (r - l > 1) { diff --git a/coding/blob_indexer.cpp b/coding/blob_indexer.cpp index 9b2f71d792..b86c10a5ae 100644 --- a/coding/blob_indexer.cpp +++ b/coding/blob_indexer.cpp @@ -38,8 +38,8 @@ uint64_t BlobIndexer::AddBlob(string const & blob) if (m_currentChunk.size() + blob.size() > m_maxUncompressedChunkSize) FlushChunk(); - m_blobChunkAndOffset.push_back(static_cast( - (m_chunkOffset.size() << BITS_IN_CHUNK_SIZE) + m_currentChunk.size())); + m_blobChunkAndOffset.push_back( + (m_chunkOffset.size() << BITS_IN_CHUNK_SIZE) + m_currentChunk.size()); m_currentChunk.insert(m_currentChunk.end(), blob.begin(), blob.end()); @@ -55,7 +55,7 @@ void BlobIndexer::FlushChunk() m_writer.Write(compressedChunk.data(), compressedChunk.size()); WriteToSink(m_writer, static_cast(m_currentChunk.size())); uint32_t const chunkPrevOffset = (m_chunkOffset.empty() ? 0 : m_chunkOffset.back()); - m_chunkOffset.push_back(static_cast(compressedChunk.size() + 4 + chunkPrevOffset)); + m_chunkOffset.push_back(compressedChunk.size() + 4 + chunkPrevOffset); m_currentChunk.clear(); } } diff --git a/coding/compressed_bit_vector.cpp b/coding/compressed_bit_vector.cpp index 285a239f67..feab4297b4 100644 --- a/coding/compressed_bit_vector.cpp +++ b/coding/compressed_bit_vector.cpp @@ -16,7 +16,7 @@ namespace { vector SerialFreqsToDistrTable(Reader & reader, uint64_t & decodeOffset, uint64_t cnt) { vector freqs; - for (uint64_t i = 0; i < cnt; ++i) freqs.push_back(static_cast(VarintDecode(reader, decodeOffset))); + for (uint64_t i = 0; i < cnt; ++i) freqs.push_back(VarintDecode(reader, decodeOffset)); return FreqsToDistrTable(freqs); } } @@ -383,12 +383,12 @@ vector DecodeCompressedBitVector(Reader & reader) { bool is_empty = (header & 4) != 0; if (!is_empty) { - posOnes.push_back(static_cast(header >> 3)); + posOnes.push_back(header >> 3); prevOnePos = posOnes.back(); } while (decodeOffset < serialSize) { - posOnes.push_back(static_cast(prevOnePos + VarintDecode(reader, decodeOffset) + 1)); + posOnes.push_back(prevOnePos + VarintDecode(reader, decodeOffset) + 1); prevOnePos = posOnes.back(); } } @@ -412,7 +412,7 @@ vector DecodeCompressedBitVector(Reader & reader) { uint32_t bitsUsed = bitsUsedVec[i]; uint64_t diff = 0; if (bitsUsed > 0) diff = ((uint64_t(1) << (bitsUsed - 1)) | bitReader.Read(bitsUsed - 1)) + 1; else diff = 1; - posOnes.push_back(static_cast(prevOnePos + diff)); + posOnes.push_back(prevOnePos + diff); prevOnePos += diff; } decodeOffset = serialSize; @@ -431,8 +431,7 @@ vector DecodeCompressedBitVector(Reader & reader) { if (!isFirstOne) zerosRangeSize = VarintDecode(reader, decodeOffset) + 1; else isFirstOne = false; uint64_t onesRangeSize = VarintDecode(reader, decodeOffset) + 1; sum += zerosRangeSize; - for (uint64_t i = sum; i < sum + onesRangeSize; ++i) - posOnes.push_back(static_cast(i)); + for (uint64_t i = sum; i < sum + onesRangeSize; ++i) posOnes.push_back(i); sum += onesRangeSize; } } @@ -476,7 +475,7 @@ vector DecodeCompressedBitVector(Reader & reader) { if (bitsUsed > 0) onesRangeSize = ((uint64_t(1) << (bitsUsed - 1)) | bitReader.Read(bitsUsed - 1)) + 1; else onesRangeSize = 1; ++i1; sum += zerosRangeSize; - for (uint64_t j = sum; j < sum + onesRangeSize; ++j) posOnes.push_back(static_cast(j)); + for (uint64_t j = sum; j < sum + onesRangeSize; ++j) posOnes.push_back(j); sum += onesRangeSize; } CHECK(i0 == cntElements0 && i1 == cntElements1, ()); diff --git a/coding/compressed_varnum_vector.cpp b/coding/compressed_varnum_vector.cpp index 538458d3f5..ff5be09073 100644 --- a/coding/compressed_varnum_vector.cpp +++ b/coding/compressed_varnum_vector.cpp @@ -105,8 +105,7 @@ CompressedVarnumVectorReader::CompressedVarnumVectorReader(Reader & reader) m_supportSums = VarintDecode(m_reader, offset) != 0; vector sizesFreqs; uint64_t freqsCnt = VarintDecode(m_reader, offset); - for (uint32_t i = 0; i < freqsCnt; ++i) - sizesFreqs.push_back(static_cast(VarintDecode(m_reader, offset))); + for (uint32_t i = 0; i < freqsCnt; ++i) sizesFreqs.push_back(VarintDecode(m_reader, offset)); m_distrTable = FreqsToDistrTable(sizesFreqs); m_numsEncodedOffset = offset; diff --git a/coding/varint_vector.cpp b/coding/varint_vector.cpp index f92653bd66..b874e10cf2 100644 --- a/coding/varint_vector.cpp +++ b/coding/varint_vector.cpp @@ -56,7 +56,7 @@ void VectorBuilder::AddNum(uint64_t num) if (m_numsCount % m_numElemPerTableEntry == 0) { TableEntry tableEntry; - tableEntry.pos = static_cast(m_serialNums.size()); + tableEntry.pos = m_serialNums.size(); tableEntry.sum = m_sum; m_selectTable.push_back(tableEntry); } @@ -143,7 +143,7 @@ void Vector::FindByIndex(uint64_t index, uint32_t & serialPos, uint64_t & sumBef uint64_t num = VarintDecode(m_reader, numOffset); sum += num; } - serialPos = static_cast(numOffset - m_serialNumsOffset); + serialPos = numOffset - m_serialNumsOffset; sumBefore = sum; } @@ -191,7 +191,7 @@ void Vector::FindBySum(uint64_t sum, uint32_t & serialPos, uint64_t & sumBefore, ++countBefore; } - serialPos = static_cast(numOffset - m_serialNumsOffset); + serialPos = numOffset - m_serialNumsOffset; sumBefore = numsSum; } @@ -201,7 +201,7 @@ void Vector::Read(uint32_t & serialPos, uint64_t & num) uint64_t numOffset = m_serialNumsOffset + serialPos; num = VarintDecode(m_reader, numOffset); - serialPos = static_cast(numOffset - m_serialNumsOffset); + serialPos = numOffset - m_serialNumsOffset; } }