[master] 38881a6f3 Polish VRY_Validate()

Nils Goroll nils.goroll at uplex.de
Mon Oct 3 14:30:07 UTC 2022


commit 38881a6f38286044a488a3d4d7c93f28b094825f
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Sep 1 13:49:22 2022 +0200

    Polish VRY_Validate()
    
    Call VRY_Len() only once where the compiler does not eliminate the
    second call anyway.

diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c
index 88567674d..73bb5e15c 100644
--- a/bin/varnishd/cache/cache_vary.c
+++ b/bin/varnishd/cache/cache_vary.c
@@ -382,12 +382,13 @@ VRY_Match(struct req *req, const uint8_t *vary)
 static unsigned
 VRY_Validate(const uint8_t *vary)
 {
-	unsigned retval = 0;
+	unsigned l, retval = 0;
 
 	while (vary[2] != 0) {
-		assert(strlen((const char*)vary+3) == vary[2]);
-		retval += VRY_Len(vary);
-		vary += VRY_Len(vary);
+		assert(strlen((const char*)vary + 3) == vary[2]);
+		l = VRY_Len(vary);
+		retval += l;
+		vary += l;
 	}
 	return (retval + 3);
 }


More information about the varnish-commit mailing list