Skip to content

Commit

Permalink
Fix extensive disk I/O when in worldmap (found using profiler)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Feb 1, 2014
1 parent c27186a commit 394d459
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/worldmap/worldmap.cpp
Expand Up @@ -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());
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/worldmap/worldmap.hpp
Expand Up @@ -234,6 +234,8 @@ class WorldMap : public Screen

Vector get_camera_pos_for_tux();
void clamp_camera_position(Vector& c);
Vector last_position;
float last_target_time;

private:
WorldMap(const WorldMap&);
Expand Down

0 comments on commit 394d459

Please sign in to comment.