From 6a511aef0a70ec4c641298a5909f69e5908e2a44 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 18 Aug 2015 00:12:04 +0900 Subject: [PATCH] Use remove/push combination instead of <= for performance --- lib/nghttp2_stream.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/nghttp2_stream.c b/lib/nghttp2_stream.c index 3816712b..0b97b1a7 100644 --- a/lib/nghttp2_stream.c +++ b/lib/nghttp2_stream.c @@ -36,7 +36,7 @@ static int stream_weight_less(const void *lhsx, const void *rhsx) { lhs = nghttp2_struct_of(lhsx, nghttp2_stream, pq_entry); rhs = nghttp2_struct_of(rhsx, nghttp2_stream, pq_entry); - return lhs->cycle <= rhs->cycle; + return lhs->cycle < rhs->cycle; } void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id, @@ -210,7 +210,8 @@ void nghttp2_stream_reschedule(nghttp2_stream *stream) { DEBUGF(fprintf(stderr, "stream: stream=%d obq resched cycle=%ld\n", stream->stream_id, stream->cycle)); - nghttp2_pq_increase_key(&dep_stream->obq, &stream->pq_entry); + nghttp2_pq_remove(&dep_stream->obq, &stream->pq_entry); + nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry); dep_stream->last_writelen = stream->last_writelen; }