provide a compile-time toggle for object caching
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
diff --git a/got/Makefile b/got/Makefile
index 3462401..3227043 100644
--- a/got/Makefile
+++ b/got/Makefile
@@ -18,6 +18,7 @@ DEBUG = -O0 -g
.endif
CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
#CPLAGS += -DGOT_PACK_NO_MMAP
+#CFLAGS += -DGOT_NO_OBJ_CACHE
# For now, default to installing binary in ~/bin
GROUP!=id -g -n
diff --git a/lib/repository.c b/lib/repository.c
index c0e12e9..4cda42e 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -149,6 +149,7 @@ done:
}
+#ifndef GOT_NO_OBJ_CACHE
static const struct got_error *
cache_add(struct got_object_cache *cache, struct got_object_id *id, void *item)
{
@@ -191,6 +192,7 @@ cache_add(struct got_object_cache *cache, struct got_object_id *id, void *item)
ce->data.commit = (struct got_commit_object *)item;
break;
}
+
err = got_object_idcache_add(cache->idcache, id, ce);
if (err) {
if (err->code == GOT_ERR_OBJ_EXISTS) {
@@ -198,21 +200,21 @@ cache_add(struct got_object_cache *cache, struct got_object_id *id, void *item)
err = NULL;
}
}
-
return err;
}
+#endif
const struct got_error *
got_repo_cache_object(struct got_repository *repo, struct got_object_id *id,
struct got_object *obj)
{
+#ifndef GOT_NO_OBJ_CACHE
const struct got_error *err = NULL;
-
err = cache_add(&repo->objcache, id, obj);
if (err)
return err;
-
obj->refcnt++;
+#endif
return NULL;
}
@@ -236,13 +238,13 @@ const struct got_error *
got_repo_cache_tree(struct got_repository *repo, struct got_object_id *id,
struct got_tree_object *tree)
{
+#ifndef GOT_NO_OBJ_CACHE
const struct got_error *err = NULL;
-
err = cache_add(&repo->treecache, id, tree);
if (err)
return err;
-
tree->refcnt++;
+#endif
return NULL;
}
@@ -266,13 +268,14 @@ const struct got_error *
got_repo_cache_commit(struct got_repository *repo, struct got_object_id *id,
struct got_commit_object *commit)
{
+#ifndef GOT_NO_OBJ_CACHE
const struct got_error *err = NULL;
-
err = cache_add(&repo->commitcache, id, commit);
if (err)
return err;
commit->refcnt++;
+#endif
return NULL;
}
diff --git a/regress/repository/Makefile b/regress/repository/Makefile
index 5c429a7..42b06ff 100644
--- a/regress/repository/Makefile
+++ b/regress/repository/Makefile
@@ -10,6 +10,7 @@ LDADD = -lutil -lz
DEBUG = -O0 -g
CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
#CFLAGS += -DGOT_PACK_NO_MMAP
+#CFLAGS += -DGOT_NO_OBJ_CACHE
NOMAN = yes
diff --git a/regress/worktree/Makefile b/regress/worktree/Makefile
index f8c274e..9d0e62f 100644
--- a/regress/worktree/Makefile
+++ b/regress/worktree/Makefile
@@ -10,6 +10,7 @@ LDADD = -lutil -lz
DEBUG = -O0 -g
CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
#CFLAGS += -DGOT_PACK_NO_MMAP
+#CFLAGS += -DGOT_NO_OBJ_CACHE
NOMAN = yes
diff --git a/tog/Makefile b/tog/Makefile
index dbaa942..ae193fb 100644
--- a/tog/Makefile
+++ b/tog/Makefile
@@ -18,6 +18,7 @@ DEBUG = -O0 -g
.endif
CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
#CPLAGS += -DGOT_PACK_NO_MMAP
+#CFLAGS += -DGOT_NO_OBJ_CACHE
# For now, default to installing binary in ~/bin
GROUP!=id -g -n