Blame


1 32cb896c 2018-03-11 stsp /*
2 32cb896c 2018-03-11 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 32cb896c 2018-03-11 stsp *
4 32cb896c 2018-03-11 stsp * Permission to use, copy, modify, and distribute this software for any
5 32cb896c 2018-03-11 stsp * purpose with or without fee is hereby granted, provided that the above
6 32cb896c 2018-03-11 stsp * copyright notice and this permission notice appear in all copies.
7 32cb896c 2018-03-11 stsp *
8 32cb896c 2018-03-11 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 32cb896c 2018-03-11 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 32cb896c 2018-03-11 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 32cb896c 2018-03-11 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 32cb896c 2018-03-11 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 32cb896c 2018-03-11 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 32cb896c 2018-03-11 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 32cb896c 2018-03-11 stsp */
16 32cb896c 2018-03-11 stsp
17 bd1223b9 2018-03-14 stsp struct got_delta_cache_entry {
18 bd1223b9 2018-03-14 stsp off_t data_offset;
19 bd1223b9 2018-03-14 stsp uint8_t *delta_buf;
20 bd1223b9 2018-03-14 stsp size_t delta_len;
21 bd1223b9 2018-03-14 stsp };
22 bd1223b9 2018-03-14 stsp
23 bd1223b9 2018-03-14 stsp #define GOT_DELTA_CACHE_SIZE 1024
24 bd1223b9 2018-03-14 stsp
25 bd1223b9 2018-03-14 stsp struct got_delta_cache {
26 bd1223b9 2018-03-14 stsp char *path_packfile;
27 bd1223b9 2018-03-14 stsp struct got_delta_cache_entry deltas[GOT_DELTA_CACHE_SIZE];
28 bd1223b9 2018-03-14 stsp };
29 bd1223b9 2018-03-14 stsp
30 87c99799 2018-03-16 stsp #define GOT_PACK_CACHE_SIZE 64
31 32cb896c 2018-03-11 stsp
32 87c99799 2018-03-16 stsp struct got_pack_cache {
33 87c99799 2018-03-16 stsp struct got_packidx_v2_hdr *packidx;
34 87c99799 2018-03-16 stsp char *path_packfile;
35 87c99799 2018-03-16 stsp FILE *packfile;
36 87c99799 2018-03-16 stsp };
37 87c99799 2018-03-16 stsp
38 32cb896c 2018-03-11 stsp struct got_repository {
39 32cb896c 2018-03-11 stsp char *path;
40 4986b9d5 2018-03-12 stsp char *path_git_dir;
41 32cb896c 2018-03-11 stsp
42 87c99799 2018-03-16 stsp /*
43 87c99799 2018-03-16 stsp * The pack cache speeds up search for packed objects and
44 87c99799 2018-03-16 stsp * avoids duplicate open file handles to pack files.
45 87c99799 2018-03-16 stsp */
46 87c99799 2018-03-16 stsp struct got_pack_cache pack_cache[GOT_PACK_CACHE_SIZE];
47 bd1223b9 2018-03-14 stsp
48 bd1223b9 2018-03-14 stsp /* The delta cache speeds up reconstruction of packed objects. */
49 87c99799 2018-03-16 stsp struct got_delta_cache delta_cache[GOT_PACK_CACHE_SIZE];
50 32cb896c 2018-03-11 stsp };
51 32cb896c 2018-03-11 stsp