diff options
author | Russell Belfer <rb@github.com> | 2012-04-17 15:12:50 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-04-25 10:42:37 -0700 |
commit | 19fa2bc111d50dc2bafb1393b87b5ba119615ae2 (patch) | |
tree | 103a62cf49834958b18562f411abd18b2a438ce6 /tests-clar | |
parent | 2bc8fa0227d549006a9870620ca1f2e08a0c305e (diff) | |
download | libgit2-19fa2bc111d50dc2bafb1393b87b5ba119615ae2.tar.gz |
Convert attrs and diffs to use string pools
This converts the git attr related code (including ignores) and
the git diff related code (and implicitly the status code) to use
`git_pools` for storing strings. This reduces the number of small
blocks allocated dramatically.
Diffstat (limited to 'tests-clar')
-rw-r--r-- | tests-clar/attr/file.c | 10 | ||||
-rw-r--r-- | tests-clar/attr/lookup.c | 13 | ||||
-rw-r--r-- | tests-clar/core/pool.c | 12 |
3 files changed, 18 insertions, 17 deletions
diff --git a/tests-clar/attr/file.c b/tests-clar/attr/file.c index 7fede5025..4e1010230 100644 --- a/tests-clar/attr/file.c +++ b/tests-clar/attr/file.c @@ -11,7 +11,7 @@ void test_attr_file__simple_read(void) git_attr_assignment *assign; git_attr_rule *rule; - cl_git_pass(git_attr_file__new(&file)); + cl_git_pass(git_attr_file__new(&file, NULL)); cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr0"), file)); cl_assert_equal_s(cl_fixture("attr/attr0"), file->path); cl_assert(file->rules.length == 1); @@ -27,7 +27,6 @@ void test_attr_file__simple_read(void) cl_assert(assign != NULL); cl_assert_equal_s("binary", assign->name); cl_assert(GIT_ATTR_TRUE(assign->value)); - cl_assert(!assign->is_allocated); git_attr_file__free(file); } @@ -38,7 +37,7 @@ void test_attr_file__match_variants(void) git_attr_rule *rule; git_attr_assignment *assign; - cl_git_pass(git_attr_file__new(&file)); + cl_git_pass(git_attr_file__new(&file, NULL)); cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr1"), file)); cl_assert_equal_s(cl_fixture("attr/attr1"), file->path); cl_assert(file->rules.length == 10); @@ -56,7 +55,6 @@ void test_attr_file__match_variants(void) cl_assert_equal_s("attr0", assign->name); cl_assert(assign->name_hash == git_attr_file__name_hash(assign->name)); cl_assert(GIT_ATTR_TRUE(assign->value)); - cl_assert(!assign->is_allocated); rule = get_rule(1); cl_assert_equal_s("pat1", rule->match.pattern); @@ -125,7 +123,7 @@ void test_attr_file__assign_variants(void) git_attr_rule *rule; git_attr_assignment *assign; - cl_git_pass(git_attr_file__new(&file)); + cl_git_pass(git_attr_file__new(&file, NULL)); cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr2"), file)); cl_assert_equal_s(cl_fixture("attr/attr2"), file->path); cl_assert(file->rules.length == 11); @@ -191,7 +189,7 @@ void test_attr_file__check_attr_examples(void) git_attr_rule *rule; git_attr_assignment *assign; - cl_git_pass(git_attr_file__new(&file)); + cl_git_pass(git_attr_file__new(&file, NULL)); cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr3"), file)); cl_assert_equal_s(cl_fixture("attr/attr3"), file->path); cl_assert(file->rules.length == 3); diff --git a/tests-clar/attr/lookup.c b/tests-clar/attr/lookup.c index 4ce80e947..accd617e6 100644 --- a/tests-clar/attr/lookup.c +++ b/tests-clar/attr/lookup.c @@ -9,7 +9,7 @@ void test_attr_lookup__simple(void) git_attr_path path; const char *value = NULL; - cl_git_pass(git_attr_file__new(&file)); + cl_git_pass(git_attr_file__new(&file, NULL)); cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr0"), file)); cl_assert_equal_s(cl_fixture("attr/attr0"), file->path); cl_assert(file->rules.length == 1); @@ -127,7 +127,7 @@ void test_attr_lookup__match_variants(void) { NULL, NULL, 0, NULL } }; - cl_git_pass(git_attr_file__new(&file)); + cl_git_pass(git_attr_file__new(&file, NULL)); cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr1"), file)); cl_assert_equal_s(cl_fixture("attr/attr1"), file->path); cl_assert(file->rules.length == 10); @@ -144,6 +144,7 @@ void test_attr_lookup__match_variants(void) void test_attr_lookup__assign_variants(void) { git_attr_file *file; + struct attr_expected cases[] = { /* pat0 -> simple assign */ { "pat0", "simple", EXPECT_TRUE, NULL }, @@ -187,7 +188,7 @@ void test_attr_lookup__assign_variants(void) { NULL, NULL, 0, NULL } }; - cl_git_pass(git_attr_file__new(&file)); + cl_git_pass(git_attr_file__new(&file, NULL)); cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr2"), file)); cl_assert(file->rules.length == 11); @@ -199,6 +200,7 @@ void test_attr_lookup__assign_variants(void) void test_attr_lookup__check_attr_examples(void) { git_attr_file *file; + struct attr_expected cases[] = { { "foo.java", "diff", EXPECT_STRING, "java" }, { "foo.java", "crlf", EXPECT_FALSE, NULL }, @@ -222,7 +224,7 @@ void test_attr_lookup__check_attr_examples(void) { NULL, NULL, 0, NULL } }; - cl_git_pass(git_attr_file__new(&file)); + cl_git_pass(git_attr_file__new(&file, NULL)); cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr3"), file)); cl_assert(file->rules.length == 3); @@ -234,6 +236,7 @@ void test_attr_lookup__check_attr_examples(void) void test_attr_lookup__from_buffer(void) { git_attr_file *file; + struct attr_expected cases[] = { { "abc", "foo", EXPECT_TRUE, NULL }, { "abc", "bar", EXPECT_TRUE, NULL }, @@ -247,7 +250,7 @@ void test_attr_lookup__from_buffer(void) { NULL, NULL, 0, NULL } }; - cl_git_pass(git_attr_file__new(&file)); + cl_git_pass(git_attr_file__new(&file, NULL)); cl_git_pass(git_attr_file__from_buffer(NULL, "a* foo\nabc bar\n* baz", file)); cl_assert(file->rules.length == 3); diff --git a/tests-clar/core/pool.c b/tests-clar/core/pool.c index 3f1ed8a5a..5ed97366f 100644 --- a/tests-clar/core/pool.c +++ b/tests-clar/core/pool.c @@ -11,9 +11,8 @@ void test_core_pool__0(void) cl_git_pass(git_pool_init(&p, 1, 4000)); for (i = 1; i < 10000; i *= 2) { - cl_git_pass(git_pool_malloc(&p, i, &ptr)); + ptr = git_pool_malloc(&p, i); cl_assert(ptr != NULL); - cl_assert(git_pool__ptr_in_pool(&p, ptr)); cl_assert(!git_pool__ptr_in_pool(&p, &i)); } @@ -32,12 +31,11 @@ void test_core_pool__1(void) { int i; git_pool p; - void *ptr; cl_git_pass(git_pool_init(&p, 1, 4000)); for (i = 2010; i > 0; i--) - cl_git_pass(git_pool_malloc(&p, i, &ptr)); + cl_assert(git_pool_malloc(&p, i) != NULL); /* with fixed page size, allocation must end up with these values */ cl_assert(git_pool__open_pages(&p) == 1); @@ -48,7 +46,7 @@ void test_core_pool__1(void) cl_git_pass(git_pool_init(&p, 1, 4100)); for (i = 2010; i > 0; i--) - cl_git_pass(git_pool_malloc(&p, i, &ptr)); + cl_assert(git_pool_malloc(&p, i) != NULL); /* with fixed page size, allocation must end up with these values */ cl_assert(git_pool__open_pages(&p) == 1); @@ -71,7 +69,9 @@ void test_core_pool__2(void) cl_git_pass(git_pool_init(&p, sizeof(git_oid), 100)); for (i = 1000; i < 10000; i++) { - cl_git_pass(git_pool_malloc(&p, 1, (void **)&oid)); + oid = git_pool_malloc(&p, 1); + cl_assert(oid != NULL); + for (j = 0; j < 8; j++) oid_hex[j] = to_hex[(i >> (4 * j)) & 0x0f]; cl_git_pass(git_oid_fromstr(oid, oid_hex)); |