changeset 4443:54bed3ee58f3 libavcodec

simpify state and make code 2% faster reimar, dont hesitate to flame me for not sending patches and feel free to revert any or all of my changes to lzo.c if you dont like them
author michael
date Wed, 31 Jan 2007 10:34:13 +0000
parents b514c50250f6
children 73b81d87c846
files lzo.c
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lzo.c	Wed Jan 31 10:29:58 2007 +0000
+++ b/lzo.c	Wed Jan 31 10:34:13 2007 +0000
@@ -168,7 +168,7 @@
  * LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes
  */
 int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
-    enum {COPY, BACKPTR} state = COPY;
+    int state= 0;
     int x;
     LZOContext c;
     c.in = in;
@@ -205,9 +205,7 @@
                     break;
                 }
             }
-        } else
-        switch (state) {
-            case COPY:
+        } else if(!state){
                 cnt = get_len(&c, x, 15);
                 copy(&c, cnt + 3);
                 x = GETB(c);
@@ -219,15 +217,13 @@
                     continue;
                 cnt = 1;
                 back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1;
-                break;
-            case BACKPTR:
+        } else {
                 cnt = 0;
                 back = (GETB(c) << 2) + (x >> 2) + 1;
-                break;
         }
         copy_backptr(&c, back, cnt + 2);
+        state=
         cnt = x & 3;
-        state = cnt ? BACKPTR : COPY;
         if (cnt)
             copy(&c, cnt);
         x = GETB(c);