diff options
author | unknown <gluh@eagle.(none)> | 2007-12-13 15:56:04 +0400 |
---|---|---|
committer | unknown <gluh@eagle.(none)> | 2007-12-13 15:56:04 +0400 |
commit | 9a10c20ba912d8b872dfde7fcfc6e551e0da6118 (patch) | |
tree | e37ba43ba6ed4171e2b64ad9dbba79328c95a875 /mysys/queues.c | |
parent | 0d5caaa4a1213e7d2d52a27ed41de32f3da0c050 (diff) | |
parent | 76a5b3b976de1ad938ae46525f11992fcb392103 (diff) | |
download | mariadb-git-9a10c20ba912d8b872dfde7fcfc6e551e0da6118.tar.gz |
Merge mysql.com:/home/gluh/MySQL/Merge/5.1
into mysql.com:/home/gluh/MySQL/Merge/5.1-opt
BitKeeper/etc/ignore:
auto-union
client/mysql.cc:
Auto merged
client/mysqltest.c:
Auto merged
include/mysql_com.h:
Auto merged
libmysql/CMakeLists.txt:
Auto merged
libmysqld/lib_sql.cc:
Auto merged
mysql-test/r/archive.result:
Auto merged
mysql-test/r/create.result:
Auto merged
mysql-test/r/delayed.result:
Auto merged
mysql-test/r/func_misc.result:
Auto merged
mysql-test/r/innodb.result:
Auto merged
mysql-test/r/innodb_mysql.result:
Auto merged
mysql-test/r/merge.result:
Auto merged
mysql-test/r/ps.result:
Auto merged
mysql-test/r/type_date.result:
Auto merged
mysql-test/suite/rpl/r/rpl_innodb_bug28430.result:
Auto merged
mysql-test/t/create.test:
Auto merged
mysql-test/t/func_misc.test:
Auto merged
mysql-test/t/information_schema.test:
Auto merged
mysql-test/t/merge.test:
Auto merged
mysql-test/t/subselect.test:
Auto merged
mysql-test/t/type_date.test:
Auto merged
mysql-test/t/type_datetime.test:
Auto merged
mysql-test/t/variables.test:
Auto merged
mysys/queues.c:
Auto merged
sql/events.cc:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/ha_partition.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item.cc:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/protocol.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/set_var.h:
Auto merged
sql/slave.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_db.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_partition.cc:
Auto merged
sql/sql_plugin.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_string.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/table.cc:
Auto merged
sql/table.h:
Auto merged
storage/myisam/ha_myisam.cc:
Auto merged
storage/myisam/mi_check.c:
Auto merged
storage/myisam/mi_open.c:
Auto merged
tests/mysql_client_test.c:
Auto merged
mysql-test/lib/mtr_report.pl:
manual merge
mysql-test/r/myisam.result:
manual merge
mysql-test/r/partition.result:
manual merge
mysql-test/r/user_var.result:
manual merge
mysql-test/t/myisam.test:
manual merge
mysql-test/t/partition.test:
manual merge
mysql-test/t/user_var.test:
manual merge
sql/item.h:
manual merge
sql/item_func.cc:
manual merge
storage/myisammrg/ha_myisammrg.cc:
manual merge
Diffstat (limited to 'mysys/queues.c')
-rw-r--r-- | mysys/queues.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/mysys/queues.c b/mysys/queues.c index bc7f0b74b4f..94f49ab8f9c 100644 --- a/mysys/queues.c +++ b/mysys/queues.c @@ -61,7 +61,7 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key, queue->first_cmp_arg=first_cmp_arg; queue->max_elements=max_elements; queue->offset_to_key=offset_to_key; - queue->max_at_top= max_at_top ? (-1 ^ 1) : 0; + queue_set_max_at_top(queue, max_at_top); DBUG_RETURN(0); } @@ -137,7 +137,7 @@ int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key, queue->compare=compare; queue->first_cmp_arg=first_cmp_arg; queue->offset_to_key=offset_to_key; - queue->max_at_top= max_at_top ? (-1 ^ 1) : 0; + queue_set_max_at_top(queue, max_at_top); resize_queue(queue, max_elements); DBUG_RETURN(0); } @@ -208,16 +208,14 @@ void delete_queue(QUEUE *queue) void queue_insert(register QUEUE *queue, uchar *element) { reg2 uint idx, next; - int cmp; DBUG_ASSERT(queue->elements < queue->max_elements); queue->root[0]= element; idx= ++queue->elements; /* max_at_top swaps the comparison if we want to order by desc */ - while ((cmp= queue->compare(queue->first_cmp_arg, - element + queue->offset_to_key, - queue->root[(next= idx >> 1)] + - queue->offset_to_key)) && - (cmp ^ queue->max_at_top) < 0) + while ((queue->compare(queue->first_cmp_arg, + element + queue->offset_to_key, + queue->root[(next= idx >> 1)] + + queue->offset_to_key) * queue->max_at_top) < 0) { queue->root[idx]= queue->root[next]; idx= next; @@ -287,19 +285,17 @@ void _downheap(register QUEUE *queue, uint idx) while (idx <= half_queue) { - int cmp; next_index=idx+idx; if (next_index < elements && (queue->compare(queue->first_cmp_arg, queue->root[next_index]+offset_to_key, - queue->root[next_index+1]+offset_to_key) ^ + queue->root[next_index+1]+offset_to_key) * queue->max_at_top) > 0) next_index++; if (first && - (((cmp=queue->compare(queue->first_cmp_arg, - queue->root[next_index]+offset_to_key, - element+offset_to_key)) == 0) || - ((cmp ^ queue->max_at_top) > 0))) + (((queue->compare(queue->first_cmp_arg, + queue->root[next_index]+offset_to_key, + element+offset_to_key) * queue->max_at_top) >= 0))) { queue->root[idx]= element; return; @@ -314,7 +310,7 @@ void _downheap(register QUEUE *queue, uint idx) { if ((queue->compare(queue->first_cmp_arg, queue->root[next_index]+offset_to_key, - element+offset_to_key) ^ + element+offset_to_key) * queue->max_at_top) < 0) break; queue->root[idx]=queue->root[next_index]; @@ -334,7 +330,6 @@ void _downheap(register QUEUE *queue, uint idx) { uchar *element; uint elements,half_queue,next_index,offset_to_key; - int cmp; offset_to_key=queue->offset_to_key; element=queue->root[idx]; @@ -346,13 +341,12 @@ void _downheap(register QUEUE *queue, uint idx) if (next_index < elements && (queue->compare(queue->first_cmp_arg, queue->root[next_index]+offset_to_key, - queue->root[next_index+1]+offset_to_key) ^ + queue->root[next_index+1]+offset_to_key) * queue->max_at_top) > 0) next_index++; - if ((cmp=queue->compare(queue->first_cmp_arg, - queue->root[next_index]+offset_to_key, - element+offset_to_key)) == 0 || - (cmp ^ queue->max_at_top) > 0) + if ((queue->compare(queue->first_cmp_arg, + queue->root[next_index]+offset_to_key, + element+offset_to_key) * queue->max_at_top) >= 0) break; queue->root[idx]=queue->root[next_index]; idx=next_index; |