MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / queue_insert

Function queue_insert

mysys/queues.c:205–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203 /* Code for insert, search and delete of elements */
204
205void queue_insert(register QUEUE *queue, uchar *element)
206{
207 reg2 uint idx, next;
208 DBUG_ASSERT(queue->elements < queue->max_elements);
209 queue->root[0]= element;
210 idx= ++queue->elements;
211 /* max_at_top swaps the comparison if we want to order by desc */
212 while ((queue->compare(queue->first_cmp_arg,
213 element + queue->offset_to_key,
214 queue->root[(next= idx >> 1)] +
215 queue->offset_to_key) * queue->max_at_top) < 0)
216 {
217 queue->root[idx]= queue->root[next];
218 idx= next;
219 }
220 queue->root[idx]= element;
221}
222
223/*
224 Does safe insert. If no more space left on the queue resize it.

Callers 4

pushMethod · 0.85
queue_insert_safeFunction · 0.85
perform_insertFunction · 0.85
thr_alarm_killFunction · 0.85

Calls 1

compareMethod · 0.45

Tested by

no test coverage detected