some style improvement

This commit is contained in:
Phuntsok Drak-pa 2018-05-23 16:27:54 +02:00
parent 7c2ea0477a
commit 34399b9b93
3 changed files with 10 additions and 8 deletions

View File

@ -30,10 +30,11 @@ using dic_t = std::map<std::pair<uint32_t, uint8_t>, uint32_t>;
const std::pair<bool, uint32_t>
dico(std::map<std::pair<uint32_t, uint8_t>, uint32_t> &t_dictionary,
uint32_t t_nr_chaine, uint8_t t_c) {
if (t_nr_chaine == 0xFFFF)
if (t_nr_chaine == 0xFFFF) {
return std::make_pair(true, t_c);
}
auto &e = t_dictionary[std::make_pair(t_nr_chaine, t_c)];
return (e) ? std::make_pair(true, e)
return (e != 0) ? std::make_pair(true, e)
: std::make_pair(
false,
(e = static_cast<

View File

@ -92,8 +92,8 @@ void compress(const std::string &t_in_file, const char *t_out_file) {
// Fichier de sortie
FILE *out =
(t_out_file) ? fopen(t_out_file, "wb") : fopen("output.lzw", "wb");
if (!out) {
(t_out_file != nullptr) ? fopen(t_out_file, "wb") : fopen("output.lzw", "wb");
if (out == nullptr) {
std::cerr << "Error at " << __FILE__ << ":" << __LINE__ - 4
<< ": could not open output file. Aborting...\n";
input_file.close();
@ -132,8 +132,9 @@ void compress(const std::string &t_in_file, const char *t_out_file) {
chunk.reserve(static_cast<size_t>(input_file.tellg() - prev_pos));
input_file.seekg(prev_pos, std::ios::beg);
std::istreambuf_iterator<char> itr(input_file);
for (std::streamoff i = 0; i < prev_pos; ++i, ++itr)
for (std::streamoff i = 0; i < prev_pos; ++i, ++itr){
;
}
chunk.assign((itr), std::istreambuf_iterator<char>());
}
uvec ret{};

View File

@ -54,7 +54,6 @@ void help() {
}
int main(int argc, char *argv[]) {
if constexpr (debug_mode) {
for (int i = 0; i < argc; ++i)
printf("argv[%d] = %s\n", i, argv[i]);
@ -160,7 +159,8 @@ int main(int argc, char *argv[]) {
} else {
puts("Not yet implemented :(");
/*
Inversion des types du dictionnaire pour retrouver les chaînes plus aisément
Inversion des types du dictionnaire pour retrouver les chaînes plus
aisément
*/
}