From cc0860dfeac4c0f9917d3e96fd9b709df1fafff2 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Fri, 13 Nov 2009 06:01:47 -0800 Subject: exclude.cc: revert _find_exclude_root() speed-up Was causing memory problems. --- crawl-ref/source/exclude.cc | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'crawl-ref/source/exclude.cc') diff --git a/crawl-ref/source/exclude.cc b/crawl-ref/source/exclude.cc index 6b7e3a9ae7..73f99b167f 100644 --- a/crawl-ref/source/exclude.cc +++ b/crawl-ref/source/exclude.cc @@ -19,9 +19,6 @@ #include "tutorial.h" #include "view.h" -typedef std::map exclmap; -static exclmap _curr_excludes_map; - static bool _mon_needs_auto_exclude(const monsters *mon, bool sleepy = false) { if (mons_is_stationary(mon)) @@ -157,27 +154,20 @@ bool travel_exclude::in_bounds(const coord_def &p) const void _mark_excludes_non_updated(const coord_def &p) { - _curr_excludes_map.clear(); - - for (exclvec::iterator it = curr_excludes.begin(); + for (exclvec::iterator it = curr_excludes.begin(); it != curr_excludes.end(); ++it) { it->uptodate = it->uptodate && it->in_bounds(p); - _curr_excludes_map[it->pos] = &(*it); - } + } } -static void _update_exclusion_los(bool all=false) +void _update_exclusion_los(bool all=false) { - _curr_excludes_map.clear(); - for (exclvec::iterator it = curr_excludes.begin(); it != curr_excludes.end(); ++it) { if (all || !it->uptodate) it->set_los(); - - _curr_excludes_map[it->pos] = &(*it); } } @@ -212,11 +202,9 @@ bool is_excluded(const coord_def &p, const exclvec &exc) static travel_exclude *_find_exclude_root(const coord_def &p) { - exclmap::iterator it = _curr_excludes_map.find(p); - - if (it !=_curr_excludes_map.end()) - return it->second; - + for (unsigned int i = 0; i < curr_excludes.size(); ++i) + if (curr_excludes[i].pos == p) + return (&curr_excludes[i]); return (NULL); } @@ -271,7 +259,6 @@ void clear_excludes() #endif curr_excludes.clear(); - _curr_excludes_map.clear(); clear_level_exclusion_annotation(); _exclude_update(); @@ -300,7 +287,6 @@ void del_exclude(const coord_def &p) if (curr_excludes[i].pos == p) { curr_excludes.erase(curr_excludes.begin() + i); - _curr_excludes_map.erase(p); break; } _exclude_update(p); @@ -331,7 +317,6 @@ void set_exclude(const coord_def &p, int radius, bool autoexcl, bool vaultexcl) curr_excludes.push_back(travel_exclude(p, radius, autoexcl, montype, vaultexcl)); - _curr_excludes_map[p] = &curr_excludes.back(); } _exclude_update(p); @@ -406,7 +391,6 @@ void marshallExcludes(writer& outf, const exclvec& excludes) void unmarshallExcludes(reader& inf, char minorVersion, exclvec &excludes) { excludes.clear(); - _curr_excludes_map.clear(); int nexcludes = unmarshallShort(inf); if (nexcludes) { @@ -423,7 +407,6 @@ void unmarshallExcludes(reader& inf, char minorVersion, exclvec &excludes) mon = static_cast(unmarshallShort(inf)); } excludes.push_back(travel_exclude(c, radius, autoexcl, mon)); - _curr_excludes_map[c] = &curr_excludes.back(); } } } -- cgit v1.2.3-54-g00ecf