Skip to content

Commit 4fd92cf

Browse files
committed
Code simplification
1 parent d065eed commit 4fd92cf

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/entropy/HuffmanEncoder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,13 @@ int HuffmanEncoder::limitCodeLengths(const uint alphabet[], uint freqs[], uint16
215215
int HuffmanEncoder::computeCodeLengths(uint16 sizes[], uint ranks[], int count) const
216216
{
217217
// Sort ranks by increasing freqs (first key) and increasing value (second key)
218-
vector<uint> v(ranks, ranks + count);
219-
sort(v.begin(), v.end());
218+
sort(ranks, ranks + count);
220219
uint freqs[256] = { 0 };
221220
bool valid = true;
222221

223222
for (int i = 0; i < count; i++) {
224-
ranks[i] = v[i] & 0xFF;
225-
freqs[i] = v[i] >> 8;
223+
freqs[i] = ranks[i] >> 8;
224+
ranks[i] = ranks[i] & 0xFF;
226225
valid &= (freqs[i] != 0);
227226
}
228227

0 commit comments

Comments
 (0)