* [PATCH] dir: use fspathncmp() in pl_hashmap_cmp()
@ 2022-10-08 11:05 René Scharfe
2022-10-11 0:19 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2022-10-08 11:05 UTC (permalink / raw)
To: Git List, Jeff King; +Cc: Junio C Hamano
From: Jeff King <peff@peff.net>
Call fspathncmp() instead of open-coding it. This shortens the code and
makes it less repetitive.
Signed-off-by: René Scharfe <l.s.r@web.de>
---
From https://lore.kernel.org/git/YSv1XZJvYdYj1JtP@coredump.intra.peff.net/
dir.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dir.c b/dir.c
index 7d56d68355..28f4c6895b 100644
--- a/dir.c
+++ b/dir.c
@@ -669,9 +669,7 @@ int pl_hashmap_cmp(const void *cmp_data UNUSED,
? ee1->patternlen
: ee2->patternlen;
- if (ignore_case)
- return strncasecmp(ee1->pattern, ee2->pattern, min_len);
- return strncmp(ee1->pattern, ee2->pattern, min_len);
+ return fspathncmp(ee1->pattern, ee2->pattern, min_len);
}
static char *dup_and_filter_pattern(const char *pattern)
--
2.38.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dir: use fspathncmp() in pl_hashmap_cmp()
2022-10-08 11:05 [PATCH] dir: use fspathncmp() in pl_hashmap_cmp() René Scharfe
@ 2022-10-11 0:19 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2022-10-11 0:19 UTC (permalink / raw)
To: René Scharfe; +Cc: Git List, Junio C Hamano
On Sat, Oct 08, 2022 at 01:05:43PM +0200, René Scharfe wrote:
> From: Jeff King <peff@peff.net>
>
> Call fspathncmp() instead of open-coding it. This shortens the code and
> makes it less repetitive.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> From https://lore.kernel.org/git/YSv1XZJvYdYj1JtP@coredump.intra.peff.net/
That's an old one. :) Thanks for hanging on to it.
> diff --git a/dir.c b/dir.c
> index 7d56d68355..28f4c6895b 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -669,9 +669,7 @@ int pl_hashmap_cmp(const void *cmp_data UNUSED,
> ? ee1->patternlen
> : ee2->patternlen;
>
> - if (ignore_case)
> - return strncasecmp(ee1->pattern, ee2->pattern, min_len);
> - return strncmp(ee1->pattern, ee2->pattern, min_len);
> + return fspathncmp(ee1->pattern, ee2->pattern, min_len);
> }
Unlike the other one discussed in that thread, where there is a shadow
ignore_case, we decided that this one is a true simplification.
-Peff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-11 0:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-08 11:05 [PATCH] dir: use fspathncmp() in pl_hashmap_cmp() René Scharfe
2022-10-11 0:19 ` Jeff King
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).