From e26b30a5f40c8da8fe1e2d17dc66be0836be916a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 21 Mar 2017 16:16:01 +0800 Subject: [PATCH] Refactor: initialize class variable directly --- src/webui/abstractwebapplication.cpp | 23 ++++++++--------------- src/webui/abstractwebapplication.h | 1 - 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/webui/abstractwebapplication.cpp b/src/webui/abstractwebapplication.cpp index cb496005d..0e318da5c 100644 --- a/src/webui/abstractwebapplication.cpp +++ b/src/webui/abstractwebapplication.cpp @@ -396,18 +396,11 @@ QString AbstractWebApplication::saveTmpFile(const QByteArray &data) return QString(); } -QStringMap AbstractWebApplication::initializeContentTypeByExtMap() -{ - QStringMap map; - - map["htm"] = Http::CONTENT_TYPE_HTML; - map["html"] = Http::CONTENT_TYPE_HTML; - map["css"] = Http::CONTENT_TYPE_CSS; - map["gif"] = Http::CONTENT_TYPE_GIF; - map["png"] = Http::CONTENT_TYPE_PNG; - map["js"] = Http::CONTENT_TYPE_JS; - - return map; -} - -const QStringMap AbstractWebApplication::CONTENT_TYPE_BY_EXT = AbstractWebApplication::initializeContentTypeByExtMap(); +const QStringMap AbstractWebApplication::CONTENT_TYPE_BY_EXT = { + { "htm", Http::CONTENT_TYPE_HTML }, + { "html", Http::CONTENT_TYPE_HTML }, + { "css", Http::CONTENT_TYPE_CSS }, + { "gif", Http::CONTENT_TYPE_GIF }, + { "png", Http::CONTENT_TYPE_PNG }, + { "js", Http::CONTENT_TYPE_JS } +}; diff --git a/src/webui/abstractwebapplication.h b/src/webui/abstractwebapplication.h index e0e1ed279..8d1227fc9 100644 --- a/src/webui/abstractwebapplication.h +++ b/src/webui/abstractwebapplication.h @@ -103,7 +103,6 @@ private: static void translateDocument(QString &data); static const QStringMap CONTENT_TYPE_BY_EXT; - static QStringMap initializeContentTypeByExtMap(); }; #endif // ABSTRACTWEBAPPLICATION_H