1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

device_mapper: slight improvement of tok_match

Reduce amount of unnecessary instructions for some code paths.
This commit is contained in:
Zdenek Kabelac 2024-10-09 17:16:44 +02:00
parent 92158a24a5
commit c29e3410c9
2 changed files with 14 additions and 6 deletions

View File

@ -85,14 +85,18 @@ static char *_dup_token(struct dm_pool *mem, const char *b, const char *e);
} \ } \
} while(0) } while(0)
/* match token */
static int _tok_match(const char *str, const char *b, const char *e) static int _tok_match(const char *str, const char *b, const char *e)
{ {
while (*str && (b != e)) { while (b < e) {
if (*str++ != *b++) if (!*str ||
(*str != *b))
return 0; return 0;
++str;
++b;
} }
return !(*str || (b != e)); return !*str; /* token is matching for \0 end */
} }
struct dm_config_tree *dm_config_create(void) struct dm_config_tree *dm_config_create(void)

View File

@ -85,14 +85,18 @@ static char *_dup_token(struct dm_pool *mem, const char *b, const char *e);
} \ } \
} while(0) } while(0)
/* match token */
static int _tok_match(const char *str, const char *b, const char *e) static int _tok_match(const char *str, const char *b, const char *e)
{ {
while (*str && (b != e)) { while (b < e) {
if (*str++ != *b++) if (!*str ||
(*str != *b))
return 0; return 0;
++str;
++b;
} }
return !(*str || (b != e)); return !*str; /* token is matching for \0 end */
} }
struct dm_config_tree *dm_config_create(void) struct dm_config_tree *dm_config_create(void)