diff options
| author | 2025-01-15 00:40:32 +0000 | |
|---|---|---|
| committer | 2025-01-15 00:40:55 +0000 | |
| commit | b5c5c5cb9e1c728a83596dcc7c4191d012fe1332 (patch) | |
| tree | 85ca79f151cdaf16dc20e4a78e06b9a083c14ffc /data.c | |
| parent | Don't describe as 'fatal' what are just non-retriable connection errors. (diff) | |
| download | penes-snac2-b5c5c5cb9e1c728a83596dcc7c4191d012fe1332.tar.gz penes-snac2-b5c5c5cb9e1c728a83596dcc7c4191d012fe1332.tar.xz penes-snac2-b5c5c5cb9e1c728a83596dcc7c4191d012fe1332.zip | |
Implement faster min_id handling
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 31 |
1 files changed, 31 insertions, 0 deletions
| @@ -679,6 +679,37 @@ int index_desc_first(FILE *f, char md5[MD5_HEX_SIZE], int skip) | |||
| 679 | return 1; | 679 | return 1; |
| 680 | } | 680 | } |
| 681 | 681 | ||
| 682 | int index_asc_first(FILE *f,char md5[MD5_HEX_SIZE], const char *seek_md5) | ||
| 683 | /* reads the first entry of an ascending index, starting from a given md5 */ | ||
| 684 | { | ||
| 685 | fseek(f, SEEK_SET, 0); | ||
| 686 | while (fread(md5, MD5_HEX_SIZE, 1, f)) { | ||
| 687 | md5[MD5_HEX_SIZE - 1] = '\0'; | ||
| 688 | if (strcmp(md5,seek_md5) == 0) { | ||
| 689 | return index_asc_next(f, md5); | ||
| 690 | } | ||
| 691 | } | ||
| 692 | return 0; | ||
| 693 | } | ||
| 694 | |||
| 695 | int index_asc_next(FILE *f, char md5[MD5_HEX_SIZE]) | ||
| 696 | /* reads the next entry of an ascending index */ | ||
| 697 | { | ||
| 698 | for (;;) { | ||
| 699 | /* read an md5 */ | ||
| 700 | if (!fread(md5, MD5_HEX_SIZE, 1, f)) | ||
| 701 | return 0; | ||
| 702 | |||
| 703 | /* deleted, skip */ | ||
| 704 | if (md5[0] != '-') | ||
| 705 | break; | ||
| 706 | } | ||
| 707 | |||
| 708 | md5[MD5_HEX_SIZE - 1] = '\0'; | ||
| 709 | |||
| 710 | return 1; | ||
| 711 | } | ||
| 712 | |||
| 682 | 713 | ||
| 683 | xs_list *index_list_desc(const char *fn, int skip, int show) | 714 | xs_list *index_list_desc(const char *fn, int skip, int show) |
| 684 | /* returns an index as a list, in reverse order */ | 715 | /* returns an index as a list, in reverse order */ |