diff options
author | Ron Yorston <rmy@pobox.com> | 2023-06-05 11:10:22 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-06-05 11:10:22 +0100 |
commit | 374b4e872a8981ec01707812d8822c9fb9a52d20 (patch) | |
tree | bab4ea4d9726d5e3ca98cefb1f6db873af8a4876 /shell | |
parent | 0b6aed138649cb843cbbdfe2ca5ff5e56f3a0825 (diff) | |
download | busybox-w32-374b4e872a8981ec01707812d8822c9fb9a52d20.tar.gz busybox-w32-374b4e872a8981ec01707812d8822c9fb9a52d20.tar.bz2 busybox-w32-374b4e872a8981ec01707812d8822c9fb9a52d20.zip |
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)
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 19 |
1 files changed, 14 insertions, 5 deletions
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) | |||
428 | 428 | ||
429 | #if ENABLE_PLATFORM_MINGW32 && NUM_APPLETS > 1 && \ | 429 | #if ENABLE_PLATFORM_MINGW32 && NUM_APPLETS > 1 && \ |
430 | (ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE) | 430 | (ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE) |
431 | static int | 431 | static const char *ash_path; |
432 | ash_preferred_applet_by_name(const char *name, const char *path) | 432 | |
433 | const char * | ||
434 | get_ash_path(void) | ||
435 | { | ||
436 | return ash_path; | ||
437 | } | ||
438 | |||
439 | static int NOINLINE | ||
440 | ash_applet_by_name(const char *name, const char *path) | ||
433 | { | 441 | { |
434 | int ret; | 442 | int ret; |
435 | 443 | ||
436 | ash_path = path; | 444 | ash_path = path; |
437 | ret = find_preferred_applet_by_name(name); | 445 | ret = find_applet_by_name(name); |
438 | ash_path = NULL; | 446 | ash_path = NULL; |
439 | 447 | ||
440 | return ret; | 448 | return ret; |
@@ -451,11 +459,12 @@ ash_applet_preferred(const char *name, const char *path) | |||
451 | 459 | ||
452 | return ret; | 460 | return ret; |
453 | } | 461 | } |
454 | # undef find_applet_by_name | 462 | # define find_applet_by_name(n, p) ash_applet_by_name(n, p) |
455 | # define find_applet_by_name(n, p) ash_preferred_applet_by_name(n, p) | ||
456 | # define is_applet_preferred(n, p) ash_applet_preferred(n, p) | 463 | # define is_applet_preferred(n, p) ash_applet_preferred(n, p) |
457 | #else | 464 | #else |
458 | # define find_applet_by_name(n, p) find_applet_by_name(n) | 465 | # define find_applet_by_name(n, p) find_applet_by_name(n) |
466 | # undef is_applet_preferred | ||
467 | # define is_applet_preferred(n, p) (1) | ||
459 | #endif | 468 | #endif |
460 | 469 | ||
461 | /* ============ Hash table sizes. Configurable. */ | 470 | /* ============ Hash table sizes. Configurable. */ |