From f52a35fd63cc6d570083cedc15576d01c0968d98 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 30 Jun 2014 12:58:08 -0400 Subject: implement ends_with via strip_suffix The ends_with function is essentially a simplified version of strip_suffix, in which we throw away the stripped length. Implementing it as an inline on top of strip_suffix has two advantages: 1. We save a bit of duplicated code. 2. The suffix is typically a string literal, and we call strlen on it. By making the function inline, many compilers can replace the strlen call with a constant. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- strbuf.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'strbuf.c') diff --git a/strbuf.c b/strbuf.c index ee96dcfb81..63356ccd1b 100644 --- a/strbuf.c +++ b/strbuf.c @@ -10,15 +10,6 @@ int starts_with(const char *str, const char *prefix) return 0; } -int ends_with(const char *str, const char *suffix) -{ - int len = strlen(str), suflen = strlen(suffix); - if (len < suflen) - return 0; - else - return !strcmp(str + len - suflen, suffix); -} - /* * Used as the default ->buf value, so that people can always assume * buf is non NULL and ->buf is NUL terminated even for a freshly -- cgit 1.2.3-korg