Просмотр исходного кода

libdpkg: Slightly optimize order() checks

Reorganize code to first do checks on most commonly expected character.
First digits, then alphabetical, then the tilde, followed by any non NUL
character and finally the NUL character.
Guillem Jover лет назад: 15
Родитель
Сommit
d3de9d66d6
1 измененных файлов с 6 добавлено и 6 удалено
  1. 6 6
      lib/dpkg/vercmp.c

+ 6 - 6
lib/dpkg/vercmp.c

@@ -43,16 +43,16 @@ epochsdiffer(const struct versionrevision *a,
 static int
 order(int c)
 {
-  if (c == '~')
-    return -1;
-  else if (cisdigit(c))
-    return 0;
-  else if (!c)
+  if (cisdigit(c))
     return 0;
   else if (cisalpha(c))
     return c;
-  else
+  else if (c == '~')
+    return -1;
+  else if (c)
     return c + 256;
+  else
+    return 0;
 }
 
 static int verrevcmp(const char *val, const char *ref) {