aboutsummaryrefslogtreecommitdiffstats
path: root/URPM.xs
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2013-05-23 11:35:03 +0200
committerThierry Vignaud <thierry.vignaud@gmail.com>2013-09-30 18:24:43 +0200
commit1c950dc919ef7d773e81eae7e32808c9370c321b (patch)
treeaccc931155b5ff270a7d41b260793ceb9890d59b /URPM.xs
parent829aacabd375fc1edb7b60dfde08afd2d8af0ebf (diff)
downloadperl-URPM-1c950dc919ef7d773e81eae7e32808c9370c321b.tar
perl-URPM-1c950dc919ef7d773e81eae7e32808c9370c321b.tar.gz
perl-URPM-1c950dc919ef7d773e81eae7e32808c9370c321b.tar.bz2
perl-URPM-1c950dc919ef7d773e81eae7e32808c9370c321b.tar.xz
perl-URPM-1c950dc919ef7d773e81eae7e32808c9370c321b.zip
alias N, V, R & A (saves nearly 2% of compiled size)
Diffstat (limited to 'URPM.xs')
-rw-r--r--URPM.xs76
1 files changed, 25 insertions, 51 deletions
diff --git a/URPM.xs b/URPM.xs
index 9addec2..6b56f66 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -1428,46 +1428,34 @@ Pkg_DESTROY(pkg)
void
Pkg_name(pkg)
URPM::Package pkg
+ ALIAS:
+ version = 1
+ release = 2
+ arch = 3
PPCODE:
if (pkg->info) {
- char *name;
- char *version;
-
- get_fullname_parts(pkg, &name, &version, NULL, NULL, NULL);
- if (version - name < 1) croak("invalid fullname");
- mXPUSHs(newSVpv(name, version-name-1));
- } else if (pkg->h) {
- mXPUSHs(newSVpv(get_name(pkg->h, RPMTAG_NAME), 0));
- }
-
-void
-Pkg_version(pkg)
- URPM::Package pkg
- PPCODE:
- if (pkg->info) {
- char *version;
- char *release;
-
- get_fullname_parts(pkg, NULL, &version, &release, NULL, NULL);
- if (release - version < 1) croak("invalid fullname");
- mXPUSHs(newSVpv(version, release-version-1));
- } else if (pkg->h) {
- mXPUSHs(newSVpv(get_name(pkg->h, RPMTAG_VERSION), 0));
- }
-
-void
-Pkg_release(pkg)
- URPM::Package pkg
- PPCODE:
- if (pkg->info) {
- char *release;
- char *arch;
-
- get_fullname_parts(pkg, NULL, NULL, &release, &arch, NULL);
- if (arch - release < 1) croak("invalid fullname");
- mXPUSHs(newSVpv(release, arch-release-1));
+ char *name, *version, *release, *arch, *eos;
+ char *res;
+ STRLEN end;
+
+ get_fullname_parts(pkg, &name, &version, &release, &arch, &eos);
+ switch (ix) {
+ case 1: res = version; end = release - version; break;
+ case 2: res = release; end = arch-release; break;
+ case 3: res = arch; end = eos-arch+1; break;
+ default: res = name; end = version - name;
+ }
+ if (end < 1) croak("invalid fullname");
+ mXPUSHs(newSVpv(res, end-1));
} else if (pkg->h) {
- mXPUSHs(newSVpv(get_name(pkg->h, RPMTAG_RELEASE), 0));
+ char *str;
+ switch (ix) {
+ case 1: str = get_name(pkg->h, RPMTAG_VERSION); break;
+ case 2: str = get_name(pkg->h, RPMTAG_RELEASE); break;
+ case 3: str = get_arch(pkg->h); break;
+ default: str = get_name(pkg->h, RPMTAG_NAME);
+ }
+ mXPUSHs(newSVpv(str, 0));
}
void
@@ -1503,20 +1491,6 @@ Pkg_EVR(pkg)
free(s);
}
-void
-Pkg_arch(pkg)
- URPM::Package pkg
- PPCODE:
- if (pkg->info) {
- char *arch;
- char *eos;
-
- get_fullname_parts(pkg, NULL, NULL, NULL, &arch, &eos);
- mXPUSHs(newSVpv(arch, eos-arch));
- } else if (pkg->h) {
- mXPUSHs(newSVpv(get_arch(pkg->h), 0));
- }
-
int
Pkg_is_arch_compat__XS(pkg)
URPM::Package pkg