Skip to content

Commit b1b2093

Browse files
committed
Do not unnecessarily cast format parameters
Types like strong enumerations and std::uint8_t are gracefully handled by the formatter.
1 parent 77072a1 commit b1b2093

File tree

4 files changed

+10
-24
lines changed

4 files changed

+10
-24
lines changed

fly/coders/huffman/huffman_decoder.cpp

+6-14
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ bool HuffmanDecoder::decode_binary(BitStreamReader &encoded, std::ostream &decod
4646

4747
if (!decode_codes(encoded, max_code_length))
4848
{
49-
LOGW(
50-
"Error decoding codes from stream (maximum code length = {})",
51-
static_cast<std::uint32_t>(m_max_code_length));
49+
LOGW("Error decoding codes from stream (maximum code length = {})", m_max_code_length);
5250
return false;
5351
}
5452
else if (!decode_symbols(encoded, max_code_length, chunk_size, decoded))
@@ -82,7 +80,7 @@ bool HuffmanDecoder::decode_header(BitStreamReader &encoded, std::uint32_t &chun
8280
return decode_header_version1(encoded, chunk_size);
8381

8482
default:
85-
LOGW("Decoded invalid Huffman version {}", static_cast<std::uint32_t>(huffman_version));
83+
LOGW("Decoded invalid Huffman version {}", huffman_version);
8684
break;
8785
}
8886

@@ -102,7 +100,7 @@ bool HuffmanDecoder::decode_header_version1(BitStreamReader &encoded, std::uint3
102100
}
103101
else if (encoded_chunk_size_kb == 0)
104102
{
105-
LOGW("Decoded invalid chunk size {}", static_cast<std::uint32_t>(encoded_chunk_size_kb));
103+
LOGW("Decoded invalid chunk size {}", encoded_chunk_size_kb);
106104
return false;
107105
}
108106

@@ -118,9 +116,7 @@ bool HuffmanDecoder::decode_header_version1(BitStreamReader &encoded, std::uint3
118116
(encoded_max_code_length == 0) ||
119117
(encoded_max_code_length >= std::numeric_limits<code_type>::digits))
120118
{
121-
LOGW(
122-
"Decoded invalid maximum code length {}",
123-
static_cast<std::uint32_t>(encoded_max_code_length));
119+
LOGW("Decoded invalid maximum code length {}", encoded_max_code_length);
124120
return false;
125121
}
126122

@@ -145,9 +141,7 @@ bool HuffmanDecoder::decode_codes(BitStreamReader &encoded, length_type &max_cod
145141
}
146142
else if ((counts_size == 0) || (counts_size > (m_max_code_length + 1)))
147143
{
148-
LOGW(
149-
"Decoded invalid number of code length counts {}",
150-
static_cast<std::uint32_t>(counts_size));
144+
LOGW("Decoded invalid number of code length counts {}", counts_size);
151145
return false;
152146
}
153147

@@ -176,9 +170,7 @@ bool HuffmanDecoder::decode_codes(BitStreamReader &encoded, length_type &max_cod
176170

177171
if (!encoded.read_byte(symbol))
178172
{
179-
LOGW(
180-
"Could not decode symbol of length {} bits",
181-
static_cast<std::uint32_t>(length));
173+
LOGW("Could not decode symbol of length {} bits", length);
182174
return false;
183175
}
184176

fly/coders/huffman/huffman_encoder.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ bool HuffmanEncoder::encode_binary(std::istream &decoded, BitStreamWriter &encod
3131
{
3232
if (m_max_code_length >= std::numeric_limits<code_type>::digits)
3333
{
34-
LOGW(
35-
"Maximum Huffman code length {} is too large for code_type",
36-
static_cast<std::uint32_t>(m_max_code_length));
34+
LOGW("Maximum Huffman code length {} is too large for code_type", m_max_code_length);
3735
return false;
3836
}
3937

fly/config/config_manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ConfigManager::ConfigManager(
3030
break;
3131

3232
default:
33-
LOGE("Unrecognized configuration type: {}", static_cast<int>(file_type));
33+
LOGE("Unrecognized configuration type: {}", file_type);
3434
break;
3535
}
3636
}

fly/parser/json_parser.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,7 @@ JsonParser::ParseState JsonParser::consume_token(Token token)
272272

273273
if (const Token parsed = get<Token>(); parsed != token)
274274
{
275-
JLOG(
276-
"Unexpected character '{}', was expecting '{}'",
277-
static_cast<char>(parsed),
278-
static_cast<char>(token));
279-
275+
JLOG("Unexpected character '{:c}', was expecting '{:c}'", parsed, token);
280276
return ParseState::Invalid;
281277
}
282278

@@ -409,7 +405,7 @@ JsonParser::ParseState JsonParser::consume_comment()
409405
}
410406

411407
default:
412-
JLOG("Invalid start sequence for comments: '/{}'", static_cast<char>(token));
408+
JLOG("Invalid start sequence for comments: '/{:c}'", token);
413409
return ParseState::Invalid;
414410
}
415411

0 commit comments

Comments
 (0)