diff options
author | Timo Teräs <timo.teras@iki.fi> | 2012-02-08 17:01:14 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2012-02-08 17:01:14 +0200 |
commit | fe9b4a38888f82c0e4541cf31660d1e4329ac20d (patch) | |
tree | 28b10a69d1407122088bec06786d20321368f5a8 /src/package.c | |
parent | 3320fba50d8be0f12d4d01f7c12824a4dd504ac9 (diff) | |
download | apk-tools-fe9b4a38888f82c0e4541cf31660d1e4329ac20d.tar.gz apk-tools-fe9b4a38888f82c0e4541cf31660d1e4329ac20d.tar.bz2 apk-tools-fe9b4a38888f82c0e4541cf31660d1e4329ac20d.tar.xz apk-tools-fe9b4a38888f82c0e4541cf31660d1e4329ac20d.zip |
blob: optimize spn and cspn
Diffstat (limited to 'src/package.c')
-rw-r--r-- | src/package.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/package.c b/src/package.c index 32d4564..20895cb 100644 --- a/src/package.c +++ b/src/package.c @@ -29,6 +29,15 @@ #include "apk_database.h" #include "apk_print.h" +static const apk_spn_match_def apk_spn_dependency_comparer = { + [7] = (1<<4) /*<*/ | (1<<5) /*=*/ | (1<<6) /*<*/, +}; + +static const apk_spn_match_def apk_spn_dependency_separator = { + [1] = (1<<2) /*\n*/, + [4] = (1<<0) /* */, +}; + void apk_pkg_format_plain(struct apk_package *pkg, apk_blob_t to) { /* pkgname-1.0.apk */ @@ -200,13 +209,13 @@ void apk_blob_pull_dep(apk_blob_t *b, struct apk_database *db, struct apk_depend goto fail; /* grap one token */ - if (!apk_blob_cspn(*b, " \n", &bdep, NULL)) + if (!apk_blob_cspn(*b, apk_spn_dependency_separator, &bdep, NULL)) bdep = *b; b->ptr += bdep.len; b->len -= bdep.len; /* skip also all separator chars */ - if (!apk_blob_spn(*b, " \n", NULL, b)) { + if (!apk_blob_spn(*b, apk_spn_dependency_separator, NULL, b)) { b->ptr += b->len; b->len = 0; } @@ -218,12 +227,12 @@ void apk_blob_pull_dep(apk_blob_t *b, struct apk_database *db, struct apk_depend optional = 1; } - if (apk_blob_cspn(bdep, "<>=", &bname, &bop)) { + if (apk_blob_cspn(bdep, apk_spn_dependency_comparer, &bname, &bop)) { int i; if (mask == 0) goto fail; - if (!apk_blob_spn(bop, "<>=", &bop, &bver)) + if (!apk_blob_spn(bop, apk_spn_dependency_comparer, &bop, &bver)) goto fail; mask = 0; for (i = 0; i < bop.len; i++) { |