From ca74ba6f16e401ad548c9d62c16525f10bd3f4de Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 9 Oct 2024 17:16:44 +0200 Subject: [PATCH] device_mapper: slight improvement of tok_match Reduce amount of unnecessary instructions for some code paths. --- device_mapper/libdm-config.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/device_mapper/libdm-config.c b/device_mapper/libdm-config.c index 89ce9d19a..cb28b7ce9 100644 --- a/device_mapper/libdm-config.c +++ b/device_mapper/libdm-config.c @@ -85,14 +85,19 @@ static char *_dup_token(struct dm_pool *mem, const char *b, const char *e); } \ } while(0) +/* match token */ static int _tok_match(const char *str, const char *b, const char *e) { - while (*str && (b != e)) { - if (*str++ != *b++) + while (b < e) { + if (*str != *b) return 0; + if (!*str) + return 0; + ++str; + ++b; } - return !(*str || (b != e)); + return !*str; /* token is matching for \0 end */ } struct dm_config_tree *dm_config_create(void)