From: Michael Tremer Date: Tue, 28 Jan 2025 11:02:09 +0000 (+0000) Subject: archive: Use the branch prediction macros in potentially hot code X-Git-Tag: 0.9.30~327 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f7b85a60f9a329b21b5659489df43ceb5b1bbfc;p=pakfire.git archive: Use the branch prediction macros in potentially hot code Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/archive.c b/src/pakfire/archive.c index 51e877bb..4bc41a6d 100644 --- a/src/pakfire/archive.c +++ b/src/pakfire/archive.c @@ -108,7 +108,7 @@ static ssize_t archive_file_read(struct archive* a, void* data, const void** buf // Read a block of data into the buffer size_t bytes_read = fread(file->buffer, 1, sizeof(file->buffer), file->f); - if (bytes_read < sizeof(file->buffer) && ferror(file->f)) { + if (unlikely(bytes_read < sizeof(file->buffer) && ferror(file->f))) { archive_set_error(a, errno, "Error reading file"); } @@ -123,11 +123,11 @@ static int64_t archive_file_skip(struct archive* a, void* data, off_t skip) { int r; // Skip if we don't support seek - if (file->flags & PAKFIRE_ARCHIVE_FILE_CANT_SEEK) + if (unlikely(file->flags & PAKFIRE_ARCHIVE_FILE_CANT_SEEK)) return 0; // Skip if we have been asked to do nothing - if (skip == 0) + if (unlikely(skip == 0)) return 0; // Perform seek() @@ -606,7 +606,7 @@ static int __pakfire_archive_read_metadata(struct pakfire_archive* archive, } // Format >= 6 - if (archive->format >= 6) { + if (likely(archive->format >= 6)) { // Parse PKGINFO if (strcmp(path, ".PKGINFO") == 0) { r = pakfire_archive_parse_json_metadata(archive, data, length); @@ -642,7 +642,7 @@ static int __pakfire_archive_filter_metadata(struct pakfire_archive* archive, const char* path = archive_entry_pathname(entry); // Format >= 6 - if (archive->format >= 6) { + if (likely(archive->format >= 6)) { // Anything that starts with "." is a metadata file if (*path == '.') return PAKFIRE_WALK_OK;