summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorsvoj@mysql.com/april.(none) <>2006-09-29 00:00:27 +0500
committersvoj@mysql.com/april.(none) <>2006-09-29 00:00:27 +0500
commitad7da7f1de71afbd189d36c301d4ae077fc774ab (patch)
treecb0da6feddaf396d3f2c2ed866624773c0d25da6 /mysys
parent19d9bdcecb98a31f545166c26f97a4260ac8611b (diff)
parent2de51adffab932f0592a1dd063f777ac45823663 (diff)
downloadmariadb-git-ad7da7f1de71afbd189d36c301d4ae077fc774ab.tar.gz
Merge mysql.com:/home/svoj/devel/mysql/BUG21617/mysql-4.1-engines
into mysql.com:/home/svoj/devel/mysql/BUG21617/mysql-5.0-engines
Diffstat (limited to 'mysys')
-rw-r--r--mysys/queues.c48
1 files changed, 19 insertions, 29 deletions
diff --git a/mysys/queues.c b/mysys/queues.c
index ecf1058af41..6a285ce7417 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -164,28 +164,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;
}
/* Remove item from queue */
@@ -193,16 +187,12 @@ void queue_insert(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 */