details:   http://hg.nginx.org/njs/rev/28bc6acceb0e
branches:  
changeset: 176:28bc6acceb0e
user:      Igor Sysoev <i...@sysoev.ru>
date:      Thu Sep 15 18:00:55 2016 +0300
description:
Returning an intptr_t result by rbtree comparison function
decreases overhead required to implement correct addresses
comparison without result truncation.

diffstat:

 nxt/nxt_mem_cache_pool.c    |  4 ++--
 nxt/nxt_rbtree.c            |  8 ++++----
 nxt/nxt_rbtree.h            |  2 +-
 nxt/test/rbtree_unit_test.c |  7 +++----
 4 files changed, 10 insertions(+), 11 deletions(-)

diffs (96 lines):

diff -r 70e3b2fc7a8d -r 28bc6acceb0e nxt/nxt_mem_cache_pool.c
--- a/nxt/nxt_mem_cache_pool.c  Thu Sep 15 17:37:52 2016 +0300
+++ b/nxt/nxt_mem_cache_pool.c  Thu Sep 15 18:00:55 2016 +0300
@@ -131,7 +131,7 @@ static nxt_mem_cache_block_t *
     nxt_mem_cache_alloc_cluster(nxt_mem_cache_pool_t *pool);
 static void *nxt_mem_cache_alloc_large(nxt_mem_cache_pool_t *pool,
     size_t alignment, size_t size);
-static nxt_int_t nxt_mem_cache_rbtree_compare(nxt_rbtree_node_t *node1,
+static intptr_t nxt_mem_cache_rbtree_compare(nxt_rbtree_node_t *node1,
     nxt_rbtree_node_t *node2);
 static nxt_mem_cache_block_t *nxt_mem_cache_find_block(nxt_rbtree_t *tree,
     u_char *p);
@@ -597,7 +597,7 @@ nxt_mem_cache_alloc_large(nxt_mem_cache_
 }
 
 
-static nxt_int_t
+static intptr_t
 nxt_mem_cache_rbtree_compare(nxt_rbtree_node_t *node1, nxt_rbtree_node_t 
*node2)
 {
     nxt_mem_cache_block_t  *block1, *block2;
diff -r 70e3b2fc7a8d -r 28bc6acceb0e nxt/nxt_rbtree.c
--- a/nxt/nxt_rbtree.c  Thu Sep 15 17:37:52 2016 +0300
+++ b/nxt/nxt_rbtree.c  Thu Sep 15 18:00:55 2016 +0300
@@ -176,7 +176,7 @@ nxt_rbtree_insert_fixup(nxt_rbtree_node_
 nxt_rbtree_node_t *
 nxt_rbtree_find(nxt_rbtree_t *tree, nxt_rbtree_part_t *part)
 {
-    nxt_int_t             n;
+    intptr_t              n;
     nxt_rbtree_node_t     *node, *next, *sentinel;
     nxt_rbtree_compare_t  compare;
 
@@ -210,7 +210,7 @@ nxt_rbtree_find(nxt_rbtree_t *tree, nxt_
 nxt_rbtree_node_t *
 nxt_rbtree_find_less_or_equal(nxt_rbtree_t *tree, nxt_rbtree_part_t *part)
 {
-    nxt_int_t             n;
+    intptr_t              n;
     nxt_rbtree_node_t     *node, *retval, *next, *sentinel;
     nxt_rbtree_compare_t  compare;
 
@@ -247,7 +247,7 @@ nxt_rbtree_find_less_or_equal(nxt_rbtree
 nxt_rbtree_node_t *
 nxt_rbtree_find_greater_or_equal(nxt_rbtree_t *tree, nxt_rbtree_part_t *part)
 {
-    nxt_int_t             n;
+    intptr_t              n;
     nxt_rbtree_node_t     *node, *retval, *next, *sentinel;
     nxt_rbtree_compare_t  compare;
 
@@ -284,7 +284,7 @@ nxt_rbtree_find_greater_or_equal(nxt_rbt
 void
 nxt_rbtree_delete(nxt_rbtree_t *tree, nxt_rbtree_part_t *part)
 {
-    nxt_uint_t         color;
+    uint8_t            color;
     nxt_rbtree_node_t  *node, *sentinel, *subst, *child;
 
     node = (nxt_rbtree_node_t *) part;
diff -r 70e3b2fc7a8d -r 28bc6acceb0e nxt/nxt_rbtree.h
--- a/nxt/nxt_rbtree.h  Thu Sep 15 17:37:52 2016 +0300
+++ b/nxt/nxt_rbtree.h  Thu Sep 15 18:00:55 2016 +0300
@@ -39,7 +39,7 @@ typedef struct {
 } nxt_rbtree_t;
 
 
-typedef nxt_int_t (*nxt_rbtree_compare_t)(nxt_rbtree_node_t *node1,
+typedef intptr_t (*nxt_rbtree_compare_t)(nxt_rbtree_node_t *node1,
     nxt_rbtree_node_t *node2);
 
 
diff -r 70e3b2fc7a8d -r 28bc6acceb0e nxt/test/rbtree_unit_test.c
--- a/nxt/test/rbtree_unit_test.c       Thu Sep 15 17:37:52 2016 +0300
+++ b/nxt/test/rbtree_unit_test.c       Thu Sep 15 18:00:55 2016 +0300
@@ -20,7 +20,7 @@ typedef struct {
 } nxt_rbtree_test_t;
 
 
-static nxt_int_t rbtree_unit_test_comparison(nxt_rbtree_node_t *node1,
+static intptr_t rbtree_unit_test_comparison(nxt_rbtree_node_t *node1,
     nxt_rbtree_node_t *node2);
 static nxt_int_t rbtree_unit_test_compare(uint32_t key1, uint32_t key2);
 static int nxt_cdecl rbtree_unit_test_sort_cmp(const void *one,
@@ -132,9 +132,8 @@ fail:
 }
 
 
-static nxt_int_t
-rbtree_unit_test_comparison(nxt_rbtree_node_t *node1,
-    nxt_rbtree_node_t *node2)
+static intptr_t
+rbtree_unit_test_comparison(nxt_rbtree_node_t *node1, nxt_rbtree_node_t *node2)
 {
     nxt_rbtree_test_t  *item1, *item2;
 

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to