aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-06-08 18:50:24 +0000
committerThierry Vignaud <tv@mageia.org>2012-06-08 18:50:24 +0000
commit1986d55fed70064c3f8d5fda21b10c703484da0e (patch)
treec0ff1ccae49c3a9ecd4c3f43c65b71a1810ff01a
parent9a2460bf025eda5bc00dad4ceac8a1d26ccc1d94 (diff)
downloadperl-URPM-1986d55fed70064c3f8d5fda21b10c703484da0e.tar
perl-URPM-1986d55fed70064c3f8d5fda21b10c703484da0e.tar.gz
perl-URPM-1986d55fed70064c3f8d5fda21b10c703484da0e.tar.bz2
perl-URPM-1986d55fed70064c3f8d5fda21b10c703484da0e.tar.xz
perl-URPM-1986d55fed70064c3f8d5fda21b10c703484da0e.zip
alias many flags setters (16% code saved with previous commit)
-rw-r--r--NEWS1
-rw-r--r--URPM.xs88
2 files changed, 21 insertions, 68 deletions
diff --git a/NEWS b/NEWS
index cb07860..ab0dac9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
- drop URPM::Query (broken for years)
- drop support for rpm-4.8.x
- kill functions unimplemented for years
+- reduce code size
Version 3.40 - 16 March 2012
diff --git a/URPM.xs b/URPM.xs
index a685009..447502a 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -2313,56 +2313,30 @@ int
Pkg_set_flag_skip(pkg, value=1)
URPM::Package pkg
int value
+ ALIAS:
+ set_flag_base = 1
+ set_flag_disable_obsolete = 2
+ set_flag_installed = 3
+ set_flag_requested = 4
+ set_flag_required = 5
+ set_flag_upgrade = 6
CODE:
- RETVAL = pkg->flag & FLAG_SKIP;
- if (value) pkg->flag |= FLAG_SKIP;
- else pkg->flag &= ~FLAG_SKIP;
- OUTPUT:
- RETVAL
-
-int
-Pkg_set_flag_base(pkg, value=1)
- URPM::Package pkg
- int value
- CODE:
- RETVAL = pkg->flag & FLAG_BASE;
- if (value) pkg->flag |= FLAG_BASE;
- else pkg->flag &= ~FLAG_BASE;
- OUTPUT:
- RETVAL
-
-int
-Pkg_set_flag_disable_obsolete(pkg, value=1)
- URPM::Package pkg
- int value
- CODE:
- RETVAL = pkg->flag & FLAG_DISABLE_OBSOLETE;
- if (value) pkg->flag |= FLAG_DISABLE_OBSOLETE;
- else pkg->flag &= ~FLAG_DISABLE_OBSOLETE;
- OUTPUT:
- RETVAL
-
-int
-Pkg_set_flag_installed(pkg, value=1)
- URPM::Package pkg
- int value
- CODE:
- RETVAL = pkg->flag & FLAG_INSTALLED;
- if (value) pkg->flag |= FLAG_INSTALLED;
- else pkg->flag &= ~FLAG_INSTALLED;
+ unsigned flag;
+ switch (ix) {
+ case 0: flag = FLAG_SKIP; break;
+ case 1: flag = FLAG_BASE; break;
+ case 2: flag = FLAG_DISABLE_OBSOLETE; break;
+ case 3: flag = FLAG_INSTALLED; break;
+ case 4: flag = FLAG_REQUESTED; break;
+ case 5: flag = FLAG_REQUIRED; break;
+ case 6: flag = FLAG_UPGRADE; break;
+ }
+ RETVAL = pkg->flag & flag;
+ if (value) pkg->flag |= flag;
+ else pkg->flag &= ~flag;
OUTPUT:
RETVAL
-int
-Pkg_set_flag_requested(pkg, value=1)
- URPM::Package pkg
- int value
- CODE:
- RETVAL = pkg->flag & FLAG_REQUESTED;
- if (value) pkg->flag |= FLAG_REQUESTED;
- else pkg->flag &= ~FLAG_REQUESTED;
- OUTPUT:
- RETVAL
int
Pkg_flag_required(pkg)
@@ -2390,28 +2364,6 @@ Pkg_flag_required(pkg)
RETVAL
int
-Pkg_set_flag_required(pkg, value=1)
- URPM::Package pkg
- int value
- CODE:
- RETVAL = pkg->flag & FLAG_REQUIRED;
- if (value) pkg->flag |= FLAG_REQUIRED;
- else pkg->flag &= ~FLAG_REQUIRED;
- OUTPUT:
- RETVAL
-
-int
-Pkg_set_flag_upgrade(pkg, value=1)
- URPM::Package pkg
- int value
- CODE:
- RETVAL = pkg->flag & FLAG_UPGRADE;
- if (value) pkg->flag |= FLAG_UPGRADE;
- else pkg->flag &= ~FLAG_UPGRADE;
- OUTPUT:
- RETVAL
-
-int
Pkg_flag_selected(pkg)
URPM::Package pkg
CODE: