Modernize code: very last fixes (#6290)
[oweals/minetest.git] / src / fontengine.cpp
index a4d96e0787388101684843a8d1554957bd8ad941..7ae0f32ed1dc014370a8255fba913b67d9299282 100644 (file)
@@ -46,8 +46,8 @@ FontEngine::FontEngine(Settings* main_settings, gui::IGUIEnvironment* env) :
        m_env(env)
 {
 
-       for (unsigned int i = 0; i < FM_MaxMode; i++) {
-               m_default_size[i] = (FontMode) FONT_SIZE_UNSPECIFIED;
+       for (u32 &i : m_default_size) {
+               i = (FontMode) FONT_SIZE_UNSPECIFIED;
        }
 
        assert(m_settings != NULL); // pre-condition
@@ -113,15 +113,13 @@ FontEngine::~FontEngine()
 /******************************************************************************/
 void FontEngine::cleanCache()
 {
-       for ( unsigned int i = 0; i < FM_MaxMode; i++) {
+       for (auto &font_cache_it : m_font_cache) {
 
-               for (std::map<unsigned int, irr::gui::IGUIFont*>::iterator iter
-                               = m_font_cache[i].begin();
-                               iter != m_font_cache[i].end(); ++iter) {
-                       iter->second->drop();
-                       iter->second = NULL;
+               for (auto &font_it : font_cache_it) {
+                       font_it.second->drop();
+                       font_it.second = NULL;
                }
-               m_font_cache[i].clear();
+               font_cache_it.clear();
        }
 }
 
@@ -370,7 +368,7 @@ void FontEngine::initSimpleFont(unsigned int basesize, FontMode mode)
 {
        assert(mode == FM_Simple || mode == FM_SimpleMono); // pre-condition
 
-       std::string font_path = "";
+       std::string font_path;
        if (mode == FM_Simple) {
                font_path = m_settings->get("font_path");
        } else {