From a09a480c6d3d2ef7633bea55bfd3cf5457b04086 Mon Sep 17 00:00:00 2001
From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Date: Tue, 4 Aug 2020 19:56:04 +0900
Subject: [PATCH] Better ordering on resend

---
 lib/ngtcp2_rtb.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/lib/ngtcp2_rtb.c b/lib/ngtcp2_rtb.c
index bbbea2d8..cd8585e2 100644
--- a/lib/ngtcp2_rtb.c
+++ b/lib/ngtcp2_rtb.c
@@ -143,19 +143,6 @@ void ngtcp2_frame_chain_list_del(ngtcp2_frame_chain *frc,
   }
 }
 
-static void frame_chain_insert(ngtcp2_frame_chain **pfrc,
-                               ngtcp2_frame_chain *frc) {
-  ngtcp2_frame_chain **plast;
-
-  assert(frc);
-
-  for (plast = &frc; *plast; plast = &(*plast)->next)
-    ;
-
-  *plast = *pfrc;
-  *pfrc = frc;
-}
-
 int ngtcp2_frame_chain_binder_new(ngtcp2_frame_chain_binder **pbinder,
                                   const ngtcp2_mem *mem) {
   *pbinder = ngtcp2_mem_calloc(mem, 1, sizeof(ngtcp2_frame_chain_binder));
@@ -435,7 +422,10 @@ static int rtb_reclaim_frame(ngtcp2_rtb *rtb, int *preclaimed,
     }
 
     *preclaimed = 1;
-    frame_chain_insert(pfrc, nfrc);
+
+    nfrc->next = *pfrc;
+    *pfrc = nfrc;
+    pfrc = &nfrc->next;
   }
 
   return 0;
-- 
GitLab