From ef4a3656773acb838c516d22547a787fcd6610de Mon Sep 17 00:00:00 2001
From: Kristof Szabados <Kristof.Szabados@ericsson.com>
Date: Tue, 1 Jan 2019 10:57:56 +0100
Subject: [PATCH] only needs 2 comparisions during runtime.

Signed-off-by: Kristof Szabados <Kristof.Szabados@ericsson.com>
---
 compiler2/record_of.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/compiler2/record_of.c b/compiler2/record_of.c
index b4544edcb..b5fc1ebb5 100644
--- a/compiler2/record_of.c
+++ b/compiler2/record_of.c
@@ -3643,13 +3643,18 @@ void defRecordOfTemplate1(const struct_of_def *sdef, output_struct *output)
 	"const Restricted_Length_Template *template_ptr,"
     " int index_value, int index_template, boolean legacy)\n"
       "{\n"
-      "if (value_ptr != NULL && template_ptr != NULL)"
-      "((const %s_template*)template_ptr)"
-      "->single_value.value_elements[index_template]"
-      "->log_match((*(const %s*)value_ptr)[index_value], legacy);\n"
-      "else if (value_ptr != NULL) (*(const %s*)value_ptr)[index_value].log();\n"
-      "else if (template_ptr != NULL) ((const %s_template*)template_ptr)"
-	"->single_value.value_elements[index_template]->log();\n"
+      "if (value_ptr == NULL) {\n"
+        "if (template_ptr != NULL) {\n"
+          "((const %s_template*)template_ptr)"
+          "->single_value.value_elements[index_template]->log();\n"
+        "}\n"
+      "} else if (template_ptr == NULL) {\n"
+        "(*(const %s*)value_ptr)[index_value].log();\n"
+      "} else {\n"
+        "((const %s_template*)template_ptr)"
+        "->single_value.value_elements[index_template]"
+        "->log_match((*(const %s*)value_ptr)[index_value], legacy);\n"
+      "}\n"
       "}\n\n", name, name, name, name, name);
   }
   
-- 
GitLab