[PATCH 07/20] dix: use single return value in GetDirection

Simon Thum simon.thum at gmx.de
Wed Apr 20 14:13:22 PDT 2011


On 04/20/2011 08:28 AM, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  dix/ptrveloc.c |   17 ++++++++---------
>  1 files changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
> index d37d1d9..c23d513 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
I personally prefer to have routing calls in one line with the return,
but still it's:

Reviewed-by: Simon Thum <simon.thum at gmx.de>

Cheers,

Simon



More information about the xorg-devel mailing list