diff --git a/xcsv.cc b/xcsv.cc index 02eb1ab9c..a6d04866e 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -158,7 +158,7 @@ const QHash XcsvStyle::xcsv_tokens { }; /* a table of config file constants mapped to chars */ -const XcsvStyle::char_map_t XcsvStyle::xcsv_char_table[] = { +const QHash XcsvStyle::xcsv_char_table { { "COMMA", "," }, { "COMMASPACE", ", " }, { "SINGLEQUOTE", "'" }, @@ -172,22 +172,15 @@ const XcsvStyle::char_map_t XcsvStyle::xcsv_char_table[] = { { "SPACE", " " }, { "HASH", "#" }, { "WHITESPACE", "\\w" }, - { "PIPE", "|" }, - { nullptr, nullptr } + { "PIPE", "|" } }; // Given a keyword of "COMMASPACE", return ", ". QString XcsvStyle::xcsv_get_char_from_constant_table(const QString& key) { - static QHash substitutions; - if (substitutions.empty()) { - for (const char_map_t* cm = xcsv_char_table; !cm->key.isNull(); cm++) { - substitutions.insert(cm->key, cm->chars); - } - } - if (substitutions.contains(key)) { - return substitutions[key]; + if (xcsv_char_table.contains(key)) { + return xcsv_char_table[key]; } // No substitution found? Just return original. return key; diff --git a/xcsv.h b/xcsv.h index 85f194c06..56acc4cd2 100644 --- a/xcsv.h +++ b/xcsv.h @@ -244,12 +244,6 @@ class XcsvStyle private: /* Types */ - /* something to map config file constants to chars */ - struct char_map_t { - const QString key; - const QString chars; - }; - /* Member Functions */ static QString dequote(const QString& in); @@ -264,7 +258,7 @@ class XcsvStyle static const QHash xcsv_tokens; /* a table of config file constants mapped to chars */ - static const char_map_t xcsv_char_table[]; + static const QHash xcsv_char_table; }; class XcsvFormat : public Format