summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/env.h
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2010-07-02 16:15:55 +0200
committerAdam Borowski <kilobyte@angband.pl>2010-07-02 22:08:24 +0200
commit09e1186b462f9450a164f99b1c9476205cc95544 (patch)
tree4955e4c54ea88458f057401131af41e336662c3d /crawl-ref/source/env.h
parent9b7ba2484e8e67d6d36991db931e1092a40de350 (diff)
downloadcrawl-ref-09e1186b462f9450a164f99b1c9476205cc95544.tar.gz
crawl-ref-09e1186b462f9450a164f99b1c9476205cc95544.zip
Use a "tgrid" so we don't have to look up traps or shops linearly.
find_trap() used to take over 10% CPU in sprint. The main optimization here is bailing out early when grd() says there is no trap -- just that cuts the effort by a factor of several hundred. That makes making the loopup O(1) mostly moot, but I included it anyway since tgrid costs just 11KB of memory. To not risk breaking something for the release, if tgrid is invalid, the list of traps/shops will be searched the old way.
Diffstat (limited to 'crawl-ref/source/env.h')
-rw-r--r--crawl-ref/source/env.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/crawl-ref/source/env.h b/crawl-ref/source/env.h
index 0c6cdd79ae..9d70e35b2f 100644
--- a/crawl-ref/source/env.h
+++ b/crawl-ref/source/env.h
@@ -29,6 +29,7 @@ struct crawl_environment
FixedArray< int, GXM, GYM > igrid; // item grid
FixedArray< unsigned short, GXM, GYM > cgrid; // cloud grid
FixedArray< unsigned short, GXM, GYM > grid_colours; // colour overrides
+ FixedArray< unsigned short, GXM, GYM > tgrid; // traps, shops
map_mask level_map_mask;
map_mask level_map_ids;