diff options
author | Kai Wohlfahrt <kai.wohlfahrt@gmail.com> | 2020-06-10 16:48:52 +0100 |
---|---|---|
committer | Martin Michlmayr <tbm@cyrius.com> | 2021-01-31 09:59:02 +0800 |
commit | ff1d1d9e5c93fa84a3abcb5bb5e21013ee8f77d9 (patch) | |
tree | 6ce78371b8d99e33352a8713c6c7865450c76129 /src/csv.cc | |
parent | 0e44585153b82c9e6730e49af3fa27aeb5b82b5f (diff) | |
download | fork-ledger-ff1d1d9e5c93fa84a3abcb5bb5e21013ee8f77d9.tar.gz fork-ledger-ff1d1d9e5c93fa84a3abcb5bb5e21013ee8f77d9.tar.bz2 fork-ledger-ff1d1d9e5c93fa84a3abcb5bb5e21013ee8f77d9.zip |
Replace if/else ladder in convert with loop
Diffstat (limited to 'src/csv.cc')
-rw-r--r-- | src/csv.cc | 27 |
1 files changed, 6 insertions, 21 deletions
@@ -107,28 +107,13 @@ void csv_reader::read_index(std::istream& in) string field = read_field(instr); names.push_back(field); - if (date_mask.match(field)) - index.push_back(FIELD_DATE); - else if (date_aux_mask.match(field)) - index.push_back(FIELD_DATE_AUX); - else if (code_mask.match(field)) - index.push_back(FIELD_CODE); - else if (payee_mask.match(field)) - index.push_back(FIELD_PAYEE); - else if (credit_mask.match(field)) - index.push_back(FIELD_CREDIT); - else if (debit_mask.match(field)) - index.push_back(FIELD_DEBIT); - else if (cost_mask.match(field)) - index.push_back(FIELD_COST); - else if (total_mask.match(field)) - index.push_back(FIELD_TOTAL); - else if (note_mask.match(field)) - index.push_back(FIELD_NOTE); - else - index.push_back(FIELD_UNKNOWN); - DEBUG("csv.parse", "Header field: " << field); + for (auto& mask : masks) { + if (mask.first.match(field)) { + index.push_back(mask.second); + break; + } + } } } |