From c487caada56e3f65209e5a7818d8b41eda7983bf Mon Sep 17 00:00:00 2001
From: zooko <zooko@zooko.com>
Date: Sat, 27 Jan 2007 07:40:28 +0530
Subject: [PATCH] pyfec: remove (optimize) unused code

darcs-hash:ef50814c8891014bf6c0364197b2fde37f78ae2c
---
 pyfec/fec/fec.c | 33 +++++----------------------------
 pyfec/fec/fec.h |  7 -------
 2 files changed, 5 insertions(+), 35 deletions(-)

diff --git a/pyfec/fec/fec.c b/pyfec/fec/fec.c
index bfe5a70..485fb1d 100644
--- a/pyfec/fec/fec.c
+++ b/pyfec/fec/fec.c
@@ -584,40 +584,17 @@ fec_encode(const fec_t* code, const gf*restrict const*restrict const src, gf*res
     unsigned i, j;
     unsigned char fecnum;
     gf* p;
-    unsigned fecs_ix = 0; /* index into the fecs array */
 
     for (i=0; i<num_share_ids; i++) {
         fecnum=share_ids[i];
-        if (fecnum >= code->k) {
-            memset(fecs[fecs_ix], 0, sz);
-            p = &(code->enc_matrix[fecnum * code->k]);
-            for (j = 0; j < code->k; j++)
-                addmul (fecs[fecs_ix], src[j], p[j], sz);
-            fecs_ix++;
-        }
+        assert (fecnum >= code->k);
+        memset(fecs[i], 0, sz);
+        p = &(code->enc_matrix[fecnum * code->k]);
+        for (j = 0; j < code->k; j++)
+            addmul (fecs[i], src[j], p[j], sz);
     }
 }
 
-#if 0
-/* By turning the nested loop inside out, we might incur different cache usage and therefore go slower or faster.  However in practice I'm not able to detect a difference, since >90% of the time is spent in my Python test script anyway.  :-) */
-void
-fec_encode(const fec_t* code, const gf*restrict const*restrict const src, gf*restrict const*restrict const fecs, const unsigned char*restrict const share_ids, unsigned char num_share_ids, size_t sz) {
-    for (unsigned j=0; j < code->k; j++) {
-        unsigned fecs_ix = 0; /* index into the fecs array */
-        for (unsigned i=0; i<num_share_ids; i++) {
-            unsigned char fecnum=share_ids[i];
-            if (fecnum >= code->k) {
-                if (j == 0)
-                    memset(fecs[fecs_ix], 0, sz);
-                gf* p = &(code->enc_matrix[fecnum * code->k]);
-                addmul (fecs[fecs_ix], src[j], p[j], sz);
-                fecs_ix++;
-            }
-        }
-    }
-}
-#endif
-
 /**
  * Build decode matrix into some memory space.
  *
diff --git a/pyfec/fec/fec.h b/pyfec/fec/fec.h
index b17999c..d9056dc 100644
--- a/pyfec/fec/fec.h
+++ b/pyfec/fec/fec.h
@@ -64,13 +64,6 @@
  * OF SUCH DAMAGE.
  */
 
-/*
- * If you get a error returned (negative value) from a fec_* function, 
- * look in here for the error message.
- */
-
-extern char fec_error[];
-
 typedef unsigned char gf;
 
 typedef struct {
-- 
2.45.2