summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/coord.h
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2011-09-05 13:39:13 +0200
committerAdam Borowski <kilobyte@angband.pl>2011-09-05 13:53:07 +0200
commitac3794658015080437b42042a57a635531be578f (patch)
tree0a0b3281ecff9972187e01e7cc492a1a4418252e /crawl-ref/source/coord.h
parent476362cd7ce3225a80da69f66d2b07983b9cb2c8 (diff)
downloadcrawl-ref-ac3794658015080437b42042a57a635531be578f.tar.gz
crawl-ref-ac3794658015080437b42042a57a635531be578f.zip
Inline in_bounds().
It's a tiny function called from many tight loops. Inlining it gives ~1% speedup in non-flto builds.
Diffstat (limited to 'crawl-ref/source/coord.h')
-rw-r--r--crawl-ref/source/coord.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/crawl-ref/source/coord.h b/crawl-ref/source/coord.h
index f8171bd9e8..d83b5df0b2 100644
--- a/crawl-ref/source/coord.h
+++ b/crawl-ref/source/coord.h
@@ -1,18 +1,38 @@
#ifndef COORD_H
#define COORD_H
-bool in_bounds_x(int x);
-bool in_bounds_y(int y);
-bool in_bounds(int x, int y);
-bool map_bounds(int x, int y);
coord_def random_in_bounds();
-inline bool in_bounds(const coord_def &p)
+static inline bool in_bounds_x(int x)
+{
+ return (x > X_BOUND_1 && x < X_BOUND_2);
+}
+
+static inline bool in_bounds_y(int y)
+{
+ return (y > Y_BOUND_1 && y < Y_BOUND_2);
+}
+
+// Returns true if inside the area the player can move and dig (ie exclusive).
+static inline bool in_bounds(int x, int y)
+{
+ return (x > X_BOUND_1 && x < X_BOUND_2 && y > Y_BOUND_1 && y < Y_BOUND_2);
+}
+
+// Returns true if inside the area the player can map (ie inclusive).
+// Note that terrain features should be in_bounds() leaving an outer
+// ring of rock to frame the level.
+static inline bool map_bounds(int x, int y)
+{
+ return (x >= X_BOUND_1 && x <= X_BOUND_2 && y >= Y_BOUND_1 && y <= Y_BOUND_2);
+}
+
+static inline bool in_bounds(const coord_def &p)
{
return in_bounds(p.x, p.y);
}
-inline bool map_bounds(const coord_def &p)
+static inline bool map_bounds(const coord_def &p)
{
return map_bounds(p.x, p.y);
}