Explorar o código

cosmetics

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@39761 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz %!s(int64=15) %!d(string=hai) anos
pai
achega
609d5e2e0f
Modificáronse 4 ficheiros con 14 adicións e 11 borrados
  1. 5 0
      lib/segment/address.c
  2. 0 1
      lib/segment/pagein.c
  3. 3 7
      lib/segment/rbtree.c
  4. 6 3
      lib/segment/setup.c

+ 5 - 0
lib/segment/address.c

@@ -25,6 +25,11 @@ int segment_address_fast(const SEGMENT * SEG, int row, int col, int *n,
 	*index =
 	    ((row - (seg_r << SEG->srowbits)) << SEG->scolbits) + col -
 	    (seg_c << SEG->scolbits);
+
+	/*
+	*n = (row >> SEG->srowbits) * SEG->spr + (col >> SEG->scolbits);
+	*index = ((row & (SEG->srows - 1)) << SEG->scolbits) + (col & (SEG->scols - 1));
+	*/
     }
     /* for simple arrays */
     else {

+ 0 - 1
lib/segment/pagein.c

@@ -93,7 +93,6 @@ int segment_pagein(SEGMENT * SEG, int n)
 	cur = SEG->freeslot[--SEG->nfreeslots];
     }
 
-
     /* read in the segment */
     SEG->scb[cur].n = n;
     SEG->scb[cur].dirty = 0;

+ 3 - 7
lib/segment/rbtree.c

@@ -83,11 +83,8 @@ int rbtree_insert(struct RB_TREE *tree, void *data)
     }
     else {
 	struct RB_NODE head = { 0 };	/* False tree root */
-
 	struct RB_NODE *g, *t;	/* Grandparent & parent */
-
 	struct RB_NODE *p, *q;	/* Iterator & parent */
-
 	int dir = 0, last = 0;
 
 	/* Set up helpers */
@@ -245,7 +242,7 @@ int rbtree_remove(struct RB_TREE *tree, const void *data)
 void *rbtree_find(struct RB_TREE *tree, const void *data)
 {
     struct RB_NODE *curr_node = tree->root;
-    int cmp = 0;
+    int cmp;
 
     assert(tree && data);
 
@@ -253,9 +250,8 @@ void *rbtree_find(struct RB_TREE *tree, const void *data)
 	cmp = tree->rb_compare(curr_node->data, data);
 	if (cmp == 0)
 	    return curr_node->data;	/* found */
-	else {
-	    curr_node = curr_node->link[cmp < 0];
-	}
+
+	curr_node = curr_node->link[cmp < 0];
     }
     return NULL;
 }

+ 6 - 3
lib/segment/setup.c

@@ -135,10 +135,12 @@ int segment_setup(SEGMENT * SEG)
 
 int segment_compare(const void *sega, const void *segb)
 {
-    SEGID *a, *b;
+    SEGID *a = (SEGID *) sega;
+    SEGID *b = (SEGID *) segb;
 
-    a = (SEGID *) sega;
-    b = (SEGID *) segb;
+    return a->n < b->n ? -1 : (a->n > b->n);
+
+    /* short version of
 
     if (a->n > b->n)
 	return 1;
@@ -146,4 +148,5 @@ int segment_compare(const void *sega, const void *segb)
 	return -1;
 
     return 0;
+    */
 }