From 374b4e872a8981ec01707812d8822c9fb9a52d20 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 5 Jun 2023 11:10:22 +0100 Subject: win32: code shrink applet look-up - Remove find_preferred_applet_by_name(). Instead add a reference to is_applet_preferred() in find_applet_by_name(). - Remove the global variable ash_path. Use a static instead, accessed by calling get_ash_path(). - Mark ash_applet_by_name() as NOINLINE. Saves 64-96 bytes. (GitHub issue #329) --- shell/ash.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index b29927a83..721204c61 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -428,13 +428,21 @@ static void forkshell_print(FILE *fp0, struct forkshell *fs, const char **notes) #if ENABLE_PLATFORM_MINGW32 && NUM_APPLETS > 1 && \ (ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE) -static int -ash_preferred_applet_by_name(const char *name, const char *path) +static const char *ash_path; + +const char * +get_ash_path(void) +{ + return ash_path; +} + +static int NOINLINE +ash_applet_by_name(const char *name, const char *path) { int ret; ash_path = path; - ret = find_preferred_applet_by_name(name); + ret = find_applet_by_name(name); ash_path = NULL; return ret; @@ -451,11 +459,12 @@ ash_applet_preferred(const char *name, const char *path) return ret; } -# undef find_applet_by_name -# define find_applet_by_name(n, p) ash_preferred_applet_by_name(n, p) +# define find_applet_by_name(n, p) ash_applet_by_name(n, p) # define is_applet_preferred(n, p) ash_applet_preferred(n, p) #else # define find_applet_by_name(n, p) find_applet_by_name(n) +# undef is_applet_preferred +# define is_applet_preferred(n, p) (1) #endif /* ============ Hash table sizes. Configurable. */ -- cgit v1.2.3-55-g6feb