diff options
author | unknown <svoj@april.(none)> | 2006-10-02 15:11:08 +0500 |
---|---|---|
committer | unknown <svoj@april.(none)> | 2006-10-02 15:11:08 +0500 |
commit | a9f677dc30f7334513c54d21a55b5f5e0fef7b7d (patch) | |
tree | fbe63b7dad0fcd0ec7eff11dcd3063b22cf98251 /mysys | |
parent | 6a698c3b3aec6c88cc4083a2b24ee64f6dc8f794 (diff) | |
parent | 6fa3aa2311b3ce4af7cb2e138e8197c3adc80d43 (diff) | |
download | mariadb-git-a9f677dc30f7334513c54d21a55b5f5e0fef7b7d.tar.gz |
Merge svojtovich@bk-internal.mysql.com:/home/bk/mysql-5.1
into mysql.com:/home/svoj/devel/mysql/merge/mysql-5.1-engines
BitKeeper/etc/ignore:
auto-union
mysql-test/r/myisam.result:
Auto merged
mysql-test/t/myisam.test:
Auto merged
sql/opt_range.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/table.cc:
Auto merged
sql/share/errmsg.txt:
Auto merged
storage/archive/ha_archive.cc:
Auto merged
storage/archive/ha_archive.h:
Auto merged
sql/sql_insert.cc:
Manual merge.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/queues.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/mysys/queues.c b/mysys/queues.c index 8e572a0f195..3900ecad3f2 100644 --- a/mysys/queues.c +++ b/mysys/queues.c @@ -208,28 +208,22 @@ void delete_queue(QUEUE *queue) void queue_insert(register QUEUE *queue, byte *element) { - reg2 uint idx,next; + reg2 uint idx, next; int cmp; - -#ifndef DBUG_OFF - if (queue->elements < queue->max_elements) -#endif + 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) { - 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) - { - queue->root[idx]=queue->root[next]; - idx=next; - } - queue->root[idx]=element; + queue->root[idx]= queue->root[next]; + idx= next; } + queue->root[idx]= element; } /* @@ -262,16 +256,12 @@ int queue_insert_safe(register QUEUE *queue, byte *element) byte *queue_remove(register QUEUE *queue, uint idx) { -#ifndef DBUG_OFF - if (idx >= queue->max_elements) - return 0; -#endif - { - byte *element=queue->root[++idx]; /* Intern index starts from 1 */ - queue->root[idx]=queue->root[queue->elements--]; - _downheap(queue,idx); - return element; - } + byte *element; + DBUG_ASSERT(idx < queue->max_elements); + element= queue->root[++idx]; /* Intern index starts from 1 */ + queue->root[idx]= queue->root[queue->elements--]; + _downheap(queue, idx); + return element; } /* Fix when element on top has been replaced */ |