Skip to content

Commit

Permalink
Avoid parsing the ABI file too many times
Browse files Browse the repository at this point in the history
  • Loading branch information
bapt committed Jan 6, 2018
1 parent 87a594e commit 2d1e456
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libpkg/pkg_create.c
Expand Up @@ -306,7 +306,7 @@ pkg_load_metadata(struct pkg *pkg, const char *mfile, const char *md_dir,
const char *plist, const char *rootdir, bool testing)
{
struct pkg_manifest_key *keys = NULL;
char arch[BUFSIZ];
const char *arch;
regex_t preg;
regmatch_t pmatch[2];
int i, ret = EPKG_OK;
Expand Down Expand Up @@ -346,7 +346,7 @@ pkg_load_metadata(struct pkg *pkg, const char *mfile, const char *md_dir,

/* if no arch autodetermine it */
if (pkg->abi == NULL) {
pkg_get_myarch(arch, BUFSIZ);
arch = pkg_object_string(pkg_config_get("ABI"));
pkg->abi = xstrdup(arch);
defaultarch = true;
}
Expand Down
5 changes: 2 additions & 3 deletions libpkg/pkgdb.c
Expand Up @@ -207,16 +207,15 @@ void
pkgdb_myarch(sqlite3_context *ctx, int argc, sqlite3_value **argv)
{
const unsigned char *arch = NULL;
char myarch[BUFSIZ];

if (argc > 1) {
sqlite3_result_error(ctx, "Invalid usage of myarch\n", -1);
return;
}

if (argc == 0 || (arch = sqlite3_value_text(argv[0])) == NULL) {
pkg_get_myarch(myarch, BUFSIZ);
sqlite3_result_text(ctx, myarch, strlen(myarch), NULL);
arch = pkg_object_string(pkg_config_get("ABI"));
sqlite3_result_text(ctx, arch, strlen(arch), NULL);
return;
}
sqlite3_result_text(ctx, arch, strlen(arch), NULL);
Expand Down

0 comments on commit 2d1e456

Please sign in to comment.