summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-04-20 13:12:53 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-04-21 13:55:49 +1000
commit5f8edbe47e3915f71a20f063a9e8b49591239600 (patch)
tree5ba96ddd82691f0641e65f404ad4c60c34cc602d
parentafaa17812513232785c8c629294190629197dfd8 (diff)
dix: use single return value in GetDirection
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Simon Thum <simon.thum@gmx.de>
-rw-r--r--dix/ptrveloc.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index c0e3e6ce5..f51b0cb1a 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -516,22 +516,21 @@ DoGetDirection(int dx, int dy){
static int
GetDirection(int dx, int dy){
static int cache[DIRECTION_CACHE_SIZE][DIRECTION_CACHE_SIZE];
- int i;
+ int dir;
if (abs(dx) <= DIRECTION_CACHE_RANGE &&
abs(dy) <= DIRECTION_CACHE_RANGE) {
/* cacheable */
- i = cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy];
- if(i != 0){
- return i;
- }else{
- i = DoGetDirection(dx, dy);
- cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy] = i;
- return i;
+ dir = cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy];
+ if(dir == 0) {
+ dir = DoGetDirection(dx, dy);
+ cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy] = dir;
}
}else{
/* non-cacheable */
- return DoGetDirection(dx, dy);
+ dir = DoGetDirection(dx, dy);
}
+
+ return dir;
}
#undef DIRECTION_CACHE_RANGE