[git commit] ash: code shrink - reuse is_prefixed_with() from libbb

Denys Vlasenko vda.linux at googlemail.com
Mon Apr 3 13:19:13 UTC 2023


commit: https://git.busybox.net/busybox/commit/?id=a33d19eba8c614d113378ed07bbec0ce06227028
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
changepath                                            67      68      +1
legal_pathopt                                         70      66      -4
prefix                                                34      13     -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 1/-25)             Total: -24 bytes

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index bd3afc0c8..cb674e69c 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1852,16 +1852,18 @@ _STPUTC(int c, char *p)
 /*
  * prefix -- see if pfx is a prefix of string.
  */
-static char *
+static ALWAYS_INLINE char *
 prefix(const char *string, const char *pfx)
 {
+	return is_prefixed_with(string, pfx);
+#if 0  /* dash implementation: */
 	while (*pfx) {
 		if (*pfx++ != *string++)
 			return NULL;
 	}
 	return (char *) string;
+#endif
 }
-
 /*
  * Check for a valid number.  This should be elsewhere.
  */


More information about the busybox-cvs mailing list