Module Name: src Committed By: rillig Date: Sun Dec 17 22:46:44 UTC 2023
Modified Files: src/usr.bin/make: str.c Log Message: make: speed up pattern matching in the ':M' modifier In the common patterns where '*' is followed by a regular character, such as in the patterns '*.c' or '*.mk', search the next possible matching position in a small loop, instead of repeatedly comparing the first remaining pattern character to all special characters. To generate a diff of this commit: cvs rdiff -u -r1.100 -r1.101 src/usr.bin/make/str.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/str.c diff -u src/usr.bin/make/str.c:1.100 src/usr.bin/make/str.c:1.101 --- src/usr.bin/make/str.c:1.100 Sat Dec 16 21:26:07 2023 +++ src/usr.bin/make/str.c Sun Dec 17 22:46:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: str.c,v 1.100 2023/12/16 21:26:07 rillig Exp $ */ +/* $NetBSD: str.c,v 1.101 2023/12/17 22:46:44 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -71,7 +71,7 @@ #include "make.h" /* "@(#)str.c 5.8 (Berkeley) 6/1/90" */ -MAKE_RCSID("$NetBSD: str.c,v 1.100 2023/12/16 21:26:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: str.c,v 1.101 2023/12/17 22:46:44 rillig Exp $"); static HashTable interned_strings; @@ -375,8 +375,15 @@ match_fixed_length: if (*pat == '\\') /* match the next character exactly */ pat++; - if (*pat != *str) + if (*pat != *str) { + if (asterisk && str == fixed_str) { + while (*str != '\0' && *str != *pat) + str++; + fixed_str = str; + goto match_fixed_length; + } goto no_match; + } } if (*pat == '*') {