[vlc-commits] demux/ty: Demux: replace if-else with switch

Filip Roséen git at videolan.org
Mon Mar 20 14:36:52 CET 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Mon Mar 20 14:26:57 2017 +0100| [dbae0e30f3b0c95d714c23f495c484059d73482a] | committer: Hugo Beauzée-Luyssen

demux/ty: Demux: replace if-else with switch

A switch should be easier to maintain, while also improving
readability.

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dbae0e30f3b0c95d714c23f495c484059d73482a
---

 modules/demux/ty.c | 52 +++++++++++++++++++++-------------------------------
 1 file changed, 21 insertions(+), 31 deletions(-)

diff --git a/modules/demux/ty.c b/modules/demux/ty.c
index be82243..5b496b3 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -456,38 +456,28 @@ static int Demux( demux_t *p_demux )
                 p_rec->rec_type, p_rec->ex1, p_rec->ex2);
     }*/
 
-    if( p_rec->rec_type == 0xe0 )
+    switch( p_rec->rec_type )
     {
-        /* Video */
-        DemuxRecVideo( p_demux, p_rec, p_block_in );
-    }
-    else if ( p_rec->rec_type == 0xc0 )
-    {
-        /* Audio */
-        DemuxRecAudio( p_demux, p_rec, p_block_in );
-    }
-    else if( p_rec->rec_type == 0x01 || p_rec->rec_type == 0x02 )
-    {
-        /* Closed Captions/XDS */
-        DemuxRecCc( p_demux, p_rec, p_block_in );
-    }
-    else if ( p_rec->rec_type == 0x03 )
-    {
-        /* Tivo data services (e.g. "thumbs-up to record!")  useless for us */
-        if( p_block_in )
-            block_Release(p_block_in);
-    }
-    else if ( p_rec->rec_type == 0x05 )
-    {
-        /* Unknown, but seen regularly */
-        if( p_block_in )
-            block_Release(p_block_in);
-    }
-    else
-    {
-        msg_Dbg(p_demux, "Invalid record type 0x%02x", p_rec->rec_type );
-        if( p_block_in )
-            block_Release(p_block_in);
+        case 0xe0: /* video */
+            DemuxRecVideo( p_demux, p_rec, p_block_in );
+            break;
+
+        case 0xc0: /* audio */
+            DemuxRecAudio( p_demux, p_rec, p_block_in );
+            break;
+
+        case 0x01: /* closed caption */
+        case 0x02: /* XDS */
+            DemuxRecCc( p_demux, p_rec, p_block_in );
+            break;
+
+        default:
+            msg_Dbg(p_demux, "Invalid record type 0x%02x", p_rec->rec_type );
+
+        case 0x03: /* tivo data services */
+        case 0x05: /* unknown, but seen regularly */
+            if( p_block_in )
+                block_Release( p_block_in );
     }
 
     /* */



More information about the vlc-commits mailing list