Jelajahi Sumber

Optimized find_json_token() slightly, squashed warning, thanks to Vladimir.

Sergey Lyubka 11 tahun lalu
induk
melakukan
5579d85539
1 mengubah file dengan 1 tambahan dan 3 penghapusan
  1. 1 3
      frozen.c

+ 1 - 3
frozen.c

@@ -341,10 +341,8 @@ static int path_part_len(const char *p) {
 
 const struct json_token *find_json_token(const struct json_token *toks,
                                          const char *path) {
-  if (path == 0 || path[0] == '\0') return 0;
-  for (;;) {
+  while (path != 0 && path[0] != '\0') {
     int i, ind2 = 0, ind = -1, skip = 2, n = path_part_len(path);
-    if (path[0] == '\0') return 0;
     if (path[0] == '[') {
       if (toks->type != JSON_TYPE_ARRAY || !is_digit(path[1])) return 0;
       for (ind = 0, n = 1; path[n] != ']' && path[n] != '\0'; n++) {