diff options
author | Dan McGee <dan@archlinux.org> | 2010-12-30 01:43:44 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-12-30 01:43:44 +0100 |
commit | a58083459b096e935693d94b9cb51a447b3a1abd (patch) | |
tree | e21857a8cc0b3dbe562cfe015571280c41023729 /lib/libalpm/be_sync.c | |
parent | 126f50ab0b5ee3ed46c5a6ecae241e8af49b0fe2 (diff) | |
parent | e3c19569cfe7cd77674490b30624e71512417e0b (diff) | |
download | pacman-a58083459b096e935693d94b9cb51a447b3a1abd.tar.gz pacman-a58083459b096e935693d94b9cb51a447b3a1abd.tar.xz |
Merge branch 'fgets-perf'
Diffstat (limited to 'lib/libalpm/be_sync.c')
-rw-r--r-- | lib/libalpm/be_sync.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 137fc1b2..d0f98c20 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -219,8 +219,8 @@ static int sync_db_populate(pmdb_t *db) } #define READ_NEXT(s) do { \ - if(_alpm_archive_fgets(s, sizeof(s), archive) == NULL) goto error; \ - _alpm_strtrim(s); \ + if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \ + s = _alpm_strtrim(buf.line); \ } while(0) #define READ_AND_STORE(f) do { \ @@ -238,10 +238,10 @@ static int sync_db_populate(pmdb_t *db) static int sync_db_read(pmdb_t *db, struct archive *archive, struct archive_entry *entry) { - char line[1024]; const char *entryname = NULL; char *filename, *pkgname, *p, *q; pmpkg_t *pkg; + struct archive_read_buffer buf; ALPM_LOG_FUNC; @@ -260,6 +260,10 @@ static int sync_db_read(pmdb_t *db, struct archive *archive, struct archive_entr _alpm_log(PM_LOG_FUNCTION, "loading package data from archive entry %s\n", entryname); + memset(&buf, 0, sizeof(buf)); + /* 512K for a line length seems reasonable */ + buf.max_line_size = 512 * 1024; + /* get package and db file names */ STRDUP(pkgname, entryname, RET_ERR(PM_ERR_MEMORY, -1)); p = pkgname + strlen(pkgname); @@ -279,8 +283,9 @@ static int sync_db_read(pmdb_t *db, struct archive *archive, struct archive_entr if(strcmp(filename, "desc") == 0 || strcmp(filename, "depends") == 0 || strcmp(filename, "deltas") == 0) { - while(_alpm_archive_fgets(line, sizeof(line), archive) != NULL) { - _alpm_strtrim(line); + while(_alpm_archive_fgets(archive, &buf) == ARCHIVE_OK) { + char *line = _alpm_strtrim(buf.line); + if(strcmp(line, "%NAME%") == 0) { READ_NEXT(line); if(strcmp(line, pkg->name) != 0) { |