summaryrefslogtreecommitdiff
path: root/mysys/queues.c
diff options
context:
space:
mode:
authorunknown <svoj@april.(none)>2006-09-29 00:23:43 +0500
committerunknown <svoj@april.(none)>2006-09-29 00:23:43 +0500
commit70c6f7d2276d34b5890f074a22b6a9f3a7c9579d (patch)
tree6ddce11f9510e4862cf11cfc2d279b535e208f76 /mysys/queues.c
parent0d7fdc9ee306a2aadfa9b676ce421ead182f90dd (diff)
parent59a7f1ab5fe51755413eb75335a8bfd82975acb1 (diff)
downloadmariadb-git-70c6f7d2276d34b5890f074a22b6a9f3a7c9579d.tar.gz
Merge mysql.com:/home/svoj/devel/mysql/BUG21617/mysql-5.0-engines
into mysql.com:/home/svoj/devel/mysql/BUG21617/mysql-5.1-engines mysql-test/r/merge.result: Auto merged mysql-test/t/merge.test: Auto merged mysys/queues.c: Auto merged storage/myisammrg/myrg_open.c: Auto merged storage/myisammrg/myrg_queue.c: Auto merged
Diffstat (limited to 'mysys/queues.c')
-rw-r--r--mysys/queues.c48
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 */