xbps: merge two patches from master for performance improvements.
This commit is contained in:
parent
779cf4f716
commit
5dc6e82099
4 changed files with 118 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
||||||
# NOTE: keep this package synchronized with "srcpkgs/xbps".
|
# NOTE: keep this package synchronized with "srcpkgs/xbps".
|
||||||
pkgname=xbps-static
|
pkgname=xbps-static
|
||||||
version=0.43.1
|
version=0.43.1
|
||||||
revision=1
|
revision=2
|
||||||
build_style=configure
|
build_style=configure
|
||||||
short_desc="The XBPS package system utilities - static binaries"
|
short_desc="The XBPS package system utilities - static binaries"
|
||||||
maintainer="Juan RP <xtraeme@gmail.com>"
|
maintainer="Juan RP <xtraeme@gmail.com>"
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
From 5d7a5a646d2f6629135b3d3ada1be00c55457151 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Tue, 6 Jan 2015 07:58:45 +0100
|
||||||
|
Subject: [PATCH 1/3] xbps_repo_get_pkg_revdeps: find pkg via repo_get_xxx not
|
||||||
|
rpool_get_xxx.
|
||||||
|
|
||||||
|
---
|
||||||
|
lib/repo.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/repo.c b/lib/repo.c
|
||||||
|
index aeca621..67e556b 100644
|
||||||
|
--- lib/repo.c
|
||||||
|
+++ lib/repo.c
|
||||||
|
@@ -434,8 +434,8 @@ xbps_repo_get_pkg_revdeps(struct xbps_repo *repo, const char *pkg)
|
||||||
|
if (repo->idx == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- if (((pkgd = xbps_rpool_get_pkg(repo->xhp, pkg)) == NULL) &&
|
||||||
|
- ((pkgd = xbps_rpool_get_virtualpkg(repo->xhp, pkg)) == NULL)) {
|
||||||
|
+ if (((pkgd = xbps_repo_get_pkg(repo, pkg)) == NULL) &&
|
||||||
|
+ ((pkgd = xbps_repo_get_virtualpkg(repo, pkg)) == NULL)) {
|
||||||
|
errno = ENOENT;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.2.1
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
From cdf7fc81af26414c8729721771d948677194ecef Mon Sep 17 00:00:00 2001
|
||||||
|
From: Juan RP <xtraeme@gmail.com>
|
||||||
|
Date: Thu, 8 Jan 2015 10:32:08 +0100
|
||||||
|
Subject: [PATCH 2/3] xbps-query(8): performance improvement to the ownedby
|
||||||
|
mode with --regex.
|
||||||
|
|
||||||
|
Only compile the ERE once, rather than on any file. Found and suggested
|
||||||
|
by Christian Neukirchen (@chneukirchen).
|
||||||
|
---
|
||||||
|
NEWS | 3 +++
|
||||||
|
bin/xbps-query/ownedby.c | 23 ++++++++++++++---------
|
||||||
|
2 files changed, 17 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bin/xbps-query/ownedby.c b/bin/xbps-query/ownedby.c
|
||||||
|
index 0def81a..4e3e175 100644
|
||||||
|
--- bin/xbps-query/ownedby.c
|
||||||
|
+++ bin/xbps-query/ownedby.c
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
/*-
|
||||||
|
- * Copyright (c) 2010-2014 Juan Romero Pardines.
|
||||||
|
+ * Copyright (c) 2010-2015 Juan Romero Pardines.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@@ -37,8 +37,9 @@
|
||||||
|
#include "defs.h"
|
||||||
|
|
||||||
|
struct ffdata {
|
||||||
|
- bool regex;
|
||||||
|
+ bool rematch;
|
||||||
|
const char *pat, *repouri;
|
||||||
|
+ regex_t regex;
|
||||||
|
xbps_array_t allkeys;
|
||||||
|
xbps_dictionary_t filesd;
|
||||||
|
};
|
||||||
|
@@ -52,7 +53,6 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd,
|
||||||
|
xbps_array_t array;
|
||||||
|
xbps_object_t obj;
|
||||||
|
const char *keyname, *filestr, *typestr;
|
||||||
|
- regex_t regex;
|
||||||
|
|
||||||
|
keyname = xbps_dictionary_keysym_cstring_nocopy(key);
|
||||||
|
|
||||||
|
@@ -72,13 +72,10 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd,
|
||||||
|
xbps_dictionary_get_cstring_nocopy(obj, "file", &filestr);
|
||||||
|
if (filestr == NULL)
|
||||||
|
continue;
|
||||||
|
- if (ffd->regex) {
|
||||||
|
- if (regcomp(®ex, ffd->pat, REG_EXTENDED|REG_NOSUB) != 0)
|
||||||
|
- return;
|
||||||
|
- if (regexec(®ex, filestr, 0, 0, 0) == 0) {
|
||||||
|
+ if (ffd->rematch) {
|
||||||
|
+ if (regexec(&ffd->regex, filestr, 0, 0, 0) == 0) {
|
||||||
|
printf("%s: %s (%s)\n", pkgver, filestr, typestr);
|
||||||
|
}
|
||||||
|
- regfree(®ex);
|
||||||
|
} else {
|
||||||
|
if ((fnmatch(ffd->pat, filestr, FNM_PERIOD)) == 0)
|
||||||
|
printf("%s: %s (%s)\n", pkgver, filestr, typestr);
|
||||||
|
@@ -176,16 +173,24 @@ ownedby(struct xbps_handle *xhp, const char *pat, bool repo, bool regex)
|
||||||
|
char *rfile;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
- ffd.regex = regex;
|
||||||
|
+ ffd.rematch = false;
|
||||||
|
ffd.pat = pat;
|
||||||
|
|
||||||
|
if ((rfile = realpath(pat, NULL)) != NULL)
|
||||||
|
ffd.pat = rfile;
|
||||||
|
|
||||||
|
+ if (regex) {
|
||||||
|
+ ffd.rematch = true;
|
||||||
|
+ if (regcomp(&ffd.regex, ffd.pat, REG_EXTENDED|REG_NOSUB) != 0)
|
||||||
|
+ return EINVAL;
|
||||||
|
+ }
|
||||||
|
if (repo)
|
||||||
|
rv = xbps_rpool_foreach(xhp, repo_ownedby_cb, &ffd);
|
||||||
|
else
|
||||||
|
rv = xbps_pkgdb_foreach_cb(xhp, ownedby_pkgdb_cb, &ffd);
|
||||||
|
|
||||||
|
+ if (regex)
|
||||||
|
+ regfree(&ffd.regex);
|
||||||
|
+
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.2.1
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Template file for 'xbps'
|
# Template file for 'xbps'
|
||||||
pkgname=xbps
|
pkgname=xbps
|
||||||
version=0.43.1
|
version=0.43.1
|
||||||
revision=1
|
revision=2
|
||||||
bootstrap=yes
|
bootstrap=yes
|
||||||
build_style=configure
|
build_style=configure
|
||||||
short_desc="The XBPS package system utilities"
|
short_desc="The XBPS package system utilities"
|
||||||
|
|
Loading…
Reference in a new issue