(wrong string) ée

From: <git_AT_suckless.org>
Date: Mon, 8 May 2017 22:28:33 +0200 (CEST)

commit e19ed379f9d86c8a21515095fd8725c68f7b4426
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Mon May 8 22:25:24 2017 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Mon May 8 22:25:24 2017 +0200

    Improve performance of blind-flop
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/src/blind-flop.c b/src/blind-flop.c
index 3401f7d..c5826be 100644
--- a/src/blind-flop.c
+++ b/src/blind-flop.c
_AT_@ -8,12 +8,28 @@
 
 USAGE("")
 
+static struct stream stream;
+static char *buf, *image;
+static size_t n, m, ps;
+
+#define PROCESS(TYPE)\
+ do {\
+ size_t i, j, pst = ps / sizeof(TYPE);\
+ size_t nt = n / sizeof(TYPE);\
+ size_t mt = m / sizeof(TYPE);\
+ for (i = 0; i < pst; i++)\
+ for (j = 0; j < nt; j += pst)\
+ ((TYPE *)image)[mt - j + i] = ((TYPE *)buf)[i + j];\
+ } while (0)
+
+static void process_double(void) {PROCESS(double);}
+static void process_float (void) {PROCESS(float);}
+static void process_char (void) {PROCESS(char);}
+
 int
 main(int argc, char *argv[])
 {
- struct stream stream;
- char *buf, *image;
- size_t i, j, n, m;
+ void (*process)(void);
 
         UNOFLAGS(argc);
 
_AT_@ -22,15 +38,16 @@ main(int argc, char *argv[])
         efflush(stdout, "<stdout>");
 
         echeck_frame_size(stream.width, 1, stream.pixel_size, 0, stream.file);
- n = stream.width * stream.pixel_size;
+ n = stream.width * (ps = stream.pixel_size);
         buf = emalloc(n);
         image = emalloc(n);
 
- m = n - stream.pixel_size;
+ process = !(ps % sizeof(double)) ? process_double :
+ !(ps % sizeof(float)) ? process_float : process_char;
+
+ m = n - ps;
         while (eread_row(&stream, buf, n)) {
- for (i = 0; i < stream.pixel_size; i++)
- for (j = 0; j < n; j += stream.pixel_size)
- image[m - j + i] = buf[i + j];
+ process();
                 ewriteall(STDOUT_FILENO, image, n, "<stdout>");
         }
 
diff --git a/src/blind-transpose.c b/src/blind-transpose.c
index 5c53a0d..cc7e7d3 100644
--- a/src/blind-transpose.c
+++ b/src/blind-transpose.c
_AT_@ -33,7 +33,7 @@ main(int argc, char *argv[])
         struct stream stream;
         char *buf, *image;
         size_t n, y;
- void (*process)(char *col, char *row);
+ void (*process)(char *row, char *col);
 
         UNOFLAGS(argc);
 
Received on Mon May 08 2017 - 22:28:33 CEST

This archive was generated by hypermail 2.3.0 : Mon May 08 2017 - 22:36:18 CEST