Mesa (master): ir_print_visitor: Print empty else blocks more compactly

Ian Romanick idr at kemper.freedesktop.org
Fri Sep 3 19:01:03 UTC 2010


Module: Mesa
Branch: master
Commit: 9710d272f71c95c8145999a31e2c47e1977c698e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9710d272f71c95c8145999a31e2c47e1977c698e

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Aug 12 14:55:48 2010 -0700

ir_print_visitor: Print empty else blocks more compactly

---

 src/glsl/ir_print_visitor.cpp |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp
index f47ad87..9d81cef 100644
--- a/src/glsl/ir_print_visitor.cpp
+++ b/src/glsl/ir_print_visitor.cpp
@@ -405,19 +405,23 @@ ir_print_visitor::visit(ir_if *ir)
    printf(")\n");
 
    indent();
-   printf("(\n");
-   indentation++;
+   if (!ir->else_instructions.is_empty()) {
+      printf("(\n");
+      indentation++;
 
-   foreach_iter(exec_list_iterator, iter, ir->else_instructions) {
-      ir_instruction *const inst = (ir_instruction *) iter.get();
+      foreach_iter(exec_list_iterator, iter, ir->else_instructions) {
+	 ir_instruction *const inst = (ir_instruction *) iter.get();
 
+	 indent();
+	 inst->accept(this);
+	 printf("\n");
+      }
+      indentation--;
       indent();
-      inst->accept(this);
-      printf("\n");
+      printf("))\n");
+   } else {
+      printf("())\n");
    }
-   indentation--;
-   indent();
-   printf("))\n");
 }
 
 




More information about the mesa-commit mailing list