[Spice-devel,v2,02/43] codegen: Simplify if/else blocks

Submitted by Frediano Ziglio on July 8, 2015, 1:53 p.m.

Details

Message ID 1436363656-4266-3-git-send-email-fziglio@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 8, 2015, 1:53 p.m.
Blocks was mainly the same, reduce code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 python_modules/marshal.py | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

Patch hide | download patch | download mbox

diff --git a/python_modules/marshal.py b/python_modules/marshal.py
index b77b910..cbda2ab 100644
--- a/python_modules/marshal.py
+++ b/python_modules/marshal.py
@@ -380,25 +380,18 @@  def write_protocol_marshaller(writer, proto, is_server, private_marshallers):
             writer.ifdef(channel.attributes["ifdef"][0])
             writer.header.ifdef(channel.attributes["ifdef"][0])
         if is_server:
-            for m in channel.client_messages:
-                message = m.message_type
-                f = write_message_marshaller(writer, message, is_server, private_marshallers)
-                if channel.has_attr("ifdef") and f not in functions:
-                    functions[f] = channel.attributes["ifdef"][0]
-                elif message.has_attr("ifdef") and f not in functions:
-                    functions[f] = message.attributes["ifdef"][0]
-                else:
-                    functions[f] = True
+            messages = channel.client_messages
         else:
-            for m in channel.server_messages:
-                message = m.message_type
-                f = write_message_marshaller(writer, message, is_server, private_marshallers)
-                if channel.has_attr("ifdef") and f not in functions:
-                    functions[f] = channel.attributes["ifdef"][0]
-                elif message.has_attr("ifdef") and f not in functions:
-                    functions[f] = message.attributes["ifdef"][0]
-                else:
-                    functions[f] = True
+            messages = channel.server_messages
+	for m in messages:
+	    message = m.message_type
+	    f = write_message_marshaller(writer, message, is_server, private_marshallers)
+	    if channel.has_attr("ifdef") and f not in functions:
+		functions[f] = channel.attributes["ifdef"][0]
+	    elif message.has_attr("ifdef") and f not in functions:
+		functions[f] = message.attributes["ifdef"][0]
+	    else:
+		functions[f] = True
         if channel.has_attr("ifdef"):
             writer.endif(channel.attributes["ifdef"][0])
             writer.header.endif(channel.attributes["ifdef"][0])