MCPcopy Create free account
hub / github.com/apache/httpd / h2_iq_sort

Function h2_iq_sort

modules/http2/h2_util.c:405–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403}
404
405void h2_iq_sort(h2_iqueue *q, h2_iq_cmp *cmp, void *ctx)
406{
407 /* Assume that changes in ordering are minimal. This needs,
408 * best case, q->nelts - 1 comparisons to check that nothing
409 * changed.
410 */
411 if (q->nelts > 0) {
412 int i, ni, prev, last;
413
414 /* Start at the end of the queue and create a tail of sorted
415 * entries. Make that tail one element longer in each iteration.
416 */
417 last = i = (q->head + q->nelts - 1) % q->nalloc;
418 while (i != q->head) {
419 prev = (q->nalloc + i - 1) % q->nalloc;
420
421 ni = iq_bubble_up(q, i, prev, cmp, ctx);
422 if (ni == prev) {
423 /* i bubbled one up, bubble the new i down, which
424 * keeps all ints below i sorted. */
425 iq_bubble_down(q, i, last, cmp, ctx);
426 }
427 i = prev;
428 };
429 }
430}
431
432
433int h2_iq_shift(h2_iqueue *q)

Callers 1

h2_mplx_c1_reprioritizeFunction · 0.85

Calls 2

iq_bubble_upFunction · 0.70
iq_bubble_downFunction · 0.70

Tested by

no test coverage detected