]> Sergey Matveev's repositories - nnn.git/commitdiff
Code refatoring
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 26 Feb 2019 17:45:01 +0000 (23:15 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Thu, 28 Feb 2019 17:06:52 +0000 (22:36 +0530)
src/nnn.c

index b205126c72a17c8e2cc54f33361b1f9cc94eb29c..20f8cb3f70e7a018b3a25c72097ac8d9997f610b 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1420,23 +1420,29 @@ static int nextsel(int *presel)
        return 0;
 }
 
+static inline void swap_ent(int id1, int id2)
+{
+       static struct entry _dent, *pdent1, *pdent2;;
+
+       pdent1 = &dents[id1];
+       pdent2 = &dents[id2];
+
+       *(&_dent) = *pdent1;
+       *pdent1 = *pdent2;
+       *pdent2 = *(&_dent);
+}
+
 /*
  * Move non-matching entries to the end
  */
 static int fill(char *fltr, regex_t *re)
 {
        static int count;
-       static struct entry _dent, *pdent1, *pdent2;
 
        for (count = 0; count < ndents; ++count) {
                if (filterfn(re, dents[count].name, fltr) == 0) {
                        if (count != --ndents) {
-                               pdent1 = &dents[count];
-                               pdent2 = &dents[ndents];
-
-                               *(&_dent) = *pdent1;
-                               *pdent1 = *pdent2;
-                               *pdent2 = *(&_dent);
+                               swap_ent(count, ndents);
                                --count;
                        }