From: Tobias Markus Date: Sat, 1 Feb 2014 19:28:34 +0000 (+0100) Subject: Fix extensive disk I/O when in worldmap (found using profiler) X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=394d459a330b94ca0030673a1232d92d663e0a6b;p=supertux.git Fix extensive disk I/O when in worldmap (found using profiler) --- diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index 3061a9527..ef0500390 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -367,6 +367,11 @@ WorldMap::get_level_title(LevelTile& level) void WorldMap::get_level_target_time(LevelTile& level) { + if(last_position == tux->get_tile_pos()) { + level.target_time = last_target_time; + return; + } + try { lisp::Parser parser; const lisp::Lisp* root = parser.parse(levels_path + level.get_name()); @@ -376,6 +381,9 @@ WorldMap::get_level_target_time(LevelTile& level) return; level_lisp->get("target-time", level.target_time); + + last_position = level.pos; + last_target_time = level.target_time; } catch(std::exception& e) { log_warning << "Problem when reading level target time: " << e.what() << std::endl; return; diff --git a/src/worldmap/worldmap.hpp b/src/worldmap/worldmap.hpp index 29cd50f37..af7c104a1 100644 --- a/src/worldmap/worldmap.hpp +++ b/src/worldmap/worldmap.hpp @@ -234,6 +234,8 @@ private: Vector get_camera_pos_for_tux(); void clamp_camera_position(Vector& c); + Vector last_position; + float last_target_time; private: WorldMap(const WorldMap&);