[master] 5d0852c Use a switch-case for the fini sequence

Guillaume Quintard guillaume at varnish-software.com
Thu Sep 8 14:14:12 CEST 2016


commit 5d0852c180c7c278b4429b9925368656c7b282b1
Author: Guillaume Quintard <guillaume at varnish-software.com>
Date:   Mon Aug 29 17:40:48 2016 +0200

    Use a switch-case for the fini sequence
    
    This allows to test vgc_inistep only once and make it easier to work for
    the compiler.

diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index 7c155fb..86e69e5 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -321,16 +321,18 @@ EmitInitFini(const struct vcc *tl)
 	Fc(tl, 0, "\nstatic int\nVGC_Discard(VRT_CTX)\n{\n\n");
 
 	Fc(tl, 0, "\t(void)VGC_function_vcl_fini(ctx);\n\n");
+
+	Fc(tl, 0, "\tswitch (vgc_inistep) {\n\n");
 	VTAILQ_FOREACH_REVERSE(p, &tl->inifin, inifinhead, list) {
 		AZ(VSB_finish(p->fin));
 		if (VSB_len(p->fin)) {
-			Fc(tl, 0, "\t/* %u */\n", p->n);
-			Fc(tl, 0, "\tif (vgc_inistep >= %u) {\n", p->n);
-			Fc(tl, 0, "%s\n", VSB_data(p->fin));
-			Fc(tl, 0, "\t}\n\n");
+			Fc(tl, 0, "\t\tcase %u :\n", p->n);
+			Fc(tl, 0, "\t%s\n", VSB_data(p->fin));
+			Fc(tl, 0, "\t\t\t/* FALLTHROUGH */\n");
 		}
 		VSB_destroy(&p->fin);
 	}
+	Fc(tl, 0, "\t}\n\n");
 
 	Fc(tl, 0, "\treturn (0);\n");
 	Fc(tl, 0, "}\n");



More information about the varnish-commit mailing list