Welcome! Log In Create A New Profile

Advanced

Why subtraction is used to compare in nginx_rbtree.c?

March 24, 2015 03:40AM
When I study the rbtree of nginx I can't understand the comments. Can
someone give me a concrete example?Thanks :)

for ( ;; ) {

/*
* Timer values
* 1) are spread in small range, usually several minutes,
* 2) and overflow each 49 days, if milliseconds are stored in 32
bits.
* The comparison takes into account that overflow.
*/

/* node->key < temp->key */

p = ((ngx_rbtree_key_int_t) (node->key - temp->key) < 0)
? &temp->left : &temp->right;

if (*p == sentinel) {
break;
}

temp = *p;
}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Why subtraction is used to compare in nginx_rbtree.c?

firsta March 24, 2015 03:40AM

Re: Why subtraction is used to compare in nginx_rbtree.c?

Maxim Dounin March 24, 2015 11:44AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 289
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready