diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-05-04 21:45:11 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-05-06 13:05:25 +0300 |
commit | 1d7123d83796182f851ccccaf056063955343718 (patch) | |
tree | ca675fd3363af3584694d0db5a3b65e618ae894b /src/app_del.c | |
parent | 791f93fcbe7a543e0bb844887ba395be8ed8ea44 (diff) | |
download | apk-tools-1d7123d83796182f851ccccaf056063955343718.tar.gz apk-tools-1d7123d83796182f851ccccaf056063955343718.tar.bz2 apk-tools-1d7123d83796182f851ccccaf056063955343718.tar.xz apk-tools-1d7123d83796182f851ccccaf056063955343718.zip |
rewrite option descriptors to be single string
This reduces the number of relocations on PIE binaries, and also
reduces the executable size. Parsing of the options is slightly
sped up as only the exact matching option group parser is called.
Diffstat (limited to 'src/app_del.c')
-rw-r--r-- | src/app_del.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/app_del.c b/src/app_del.c index a978f10..989f0e9 100644 --- a/src/app_del.c +++ b/src/app_del.c @@ -21,12 +21,20 @@ struct del_ctx { int errors; }; -static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int optch, const char *optarg) +enum { + OPT_DEL_redepends, +}; + +static const char option_desc[] = + APK_OPTAPPLET + APK_OPT2n("rdepends", "r"); + +static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int opt, const char *optarg) { struct del_ctx *ctx = (struct del_ctx *) pctx; - switch (optch) { - case 'r': + switch (opt) { + case OPT_DEL_redepends: ctx->recursive_delete = 1; break; default: @@ -35,14 +43,8 @@ static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int op return 0; } -static const struct apk_option options_applet[] = { - { 'r', "rdepends" }, -}; - static const struct apk_option_group optgroup_applet = { - .name = "Delete", - .options = options_applet, - .num_options = ARRAY_SIZE(options_applet), + .desc = option_desc, .parse = option_parse_applet, }; |