diff options
author | Timo Teräs <timo.teras@iki.fi> | 2021-11-09 21:28:55 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-11-09 21:50:11 +0200 |
commit | c60b7424a0e0b12540112bc14d42f3214f214cd6 (patch) | |
tree | ecdda4565bb3498bd2318786beb663d46216f683 /src/fs_fsys.c | |
parent | 7c8f8725724a54538ddd4ae03404276725f4fb8f (diff) | |
download | apk-tools-c60b7424a0e0b12540112bc14d42f3214f214cd6.tar.gz apk-tools-c60b7424a0e0b12540112bc14d42f3214f214cd6.tar.bz2 apk-tools-c60b7424a0e0b12540112bc14d42f3214f214cd6.tar.xz apk-tools-c60b7424a0e0b12540112bc14d42f3214f214cd6.zip |
optimize apk_pathbuilder_pop to get the old length
avoids memrchr
Diffstat (limited to 'src/fs_fsys.c')
-rw-r--r-- | src/fs_fsys.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/fs_fsys.c b/src/fs_fsys.c index 7615b79..0993607 100644 --- a/src/fs_fsys.c +++ b/src/fs_fsys.c @@ -223,10 +223,10 @@ static int fsys_file_control(struct apk_fsdir *d, apk_blob_t filename, int ctrl) struct apk_ctx *ac = d->ac; char tmpname[TMPNAME_MAX], apknewname[TMPNAME_MAX]; const char *fn; - int rc = 0, atfd = apk_ctx_fd_dest(d->ac); + int n, rc = 0, atfd = apk_ctx_fd_dest(d->ac); apk_blob_t dirname = apk_pathbuilder_get(&d->pb); - apk_pathbuilder_pushb(&d->pb, filename); + n = apk_pathbuilder_pushb(&d->pb, filename); fn = apk_pathbuilder_cstr(&d->pb); switch (ctrl) { @@ -258,7 +258,7 @@ static int fsys_file_control(struct apk_fsdir *d, apk_blob_t filename, int ctrl) break; } - apk_pathbuilder_pop(&d->pb); + apk_pathbuilder_pop(&d->pb, n); return rc; } @@ -267,10 +267,11 @@ static int fsys_file_digest(struct apk_fsdir *d, apk_blob_t filename, uint8_t al struct apk_ctx *ac = d->ac; struct apk_istream *is; apk_blob_t blob; + int n; - apk_pathbuilder_pushb(&d->pb, filename); + n = apk_pathbuilder_pushb(&d->pb, filename); is = apk_istream_from_file(apk_ctx_fd_dest(ac), apk_pathbuilder_cstr(&d->pb)); - apk_pathbuilder_pop(&d->pb); + apk_pathbuilder_pop(&d->pb, n); if (IS_ERR(is)) return PTR_ERR(is); apk_digest_ctx_reset(&ac->dctx, alg); |