@matheusbsbs / matheus-bagliano / commits / 28c5d9ed2a
Fork 0

vcs-svn: drop string_pool

This reverts commit 1d73b52f5ba4184de6acf474f14668001304a10c (Add string-specific memory pool, 2010-08-09). Now that svn-fe does not need to maintain a growing collection of strings (paths) over a long period of time, the string_pool is not needed. Signed-off-by: David Barr <david.barr@cordelta.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

David Barr committed Dec 13, 2010 at 21:17 UTC 28c5d9ed2a2bc562bc8c50092f52f58b3aa08039
7 files changed +4 -224
.gitignore
-1
@@ -177,7 +177,6 @@
177 /test-run-command
178 /test-sha1
179 /test-sigchain
180 -/test-string-pool
180 /test-subprocess
181 /test-svn-fe
182 /test-treap
Makefile
+4 -8
@@ -430,7 +430,6 @@ TEST_PROGRAMS_NEED_X += test-path-utils
430 TEST_PROGRAMS_NEED_X += test-run-command
431 TEST_PROGRAMS_NEED_X += test-sha1
432 TEST_PROGRAMS_NEED_X += test-sigchain
433 -TEST_PROGRAMS_NEED_X += test-string-pool
433 TEST_PROGRAMS_NEED_X += test-subprocess
434 TEST_PROGRAMS_NEED_X += test-svn-fe
435 TEST_PROGRAMS_NEED_X += test-treap
@@ -1838,10 +1837,9 @@ ifndef NO_CURL
1837 endif
1838 XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
1839 xdiff/xmerge.o xdiff/xpatience.o
1841 -VCSSVN_OBJS = vcs-svn/string_pool.o vcs-svn/line_buffer.o \
1842 - vcs-svn/repo_tree.o vcs-svn/fast_export.o vcs-svn/svndump.o
1843 -VCSSVN_TEST_OBJS = test-obj-pool.o test-string-pool.o \
1844 - test-line-buffer.o test-treap.o
1840 +VCSSVN_OBJS = vcs-svn/line_buffer.o vcs-svn/repo_tree.o \
1841 + vcs-svn/fast_export.o vcs-svn/svndump.o
1842 +VCSSVN_TEST_OBJS = test-obj-pool.o test-line-buffer.o test-treap.o
1843 OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS)
1844
1845 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
@@ -1965,7 +1963,7 @@ xdiff-interface.o $(XDIFF_OBJS): \
1963 xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
1964
1965 $(VCSSVN_OBJS) $(VCSSVN_TEST_OBJS): $(LIB_H) \
1968 - vcs-svn/obj_pool.h vcs-svn/trp.h vcs-svn/string_pool.h \
1966 + vcs-svn/obj_pool.h vcs-svn/trp.h \
1967 vcs-svn/line_buffer.h vcs-svn/repo_tree.h vcs-svn/fast_export.h \
1968 vcs-svn/svndump.h
1969
@@ -2133,8 +2131,6 @@ test-line-buffer$X: vcs-svn/lib.a
2131
2132 test-parse-options$X: parse-options.o
2133
2136 -test-string-pool$X: vcs-svn/lib.a
2137 -
2134 test-svn-fe$X: vcs-svn/lib.a
2135
2136 .PRECIOUS: $(TEST_OBJS)
t/t0080-vcs-svn.sh
-16
@@ -76,22 +76,6 @@ test_expect_success 'obj pool: high-water mark' '
76 test_cmp expected actual
77 '
78
79 -test_expect_success 'string pool' '
80 - echo a does not equal b >expected.differ &&
81 - echo a equals a >expected.match &&
82 - echo equals equals equals >expected.matchmore &&
83 -
84 - test-string-pool "a,--b" >actual.differ &&
85 - test-string-pool "a,a" >actual.match &&
86 - test-string-pool "equals-equals" >actual.matchmore &&
87 - test_must_fail test-string-pool a,a,a &&
88 - test_must_fail test-string-pool a &&
89 -
90 - test_cmp expected.differ actual.differ &&
91 - test_cmp expected.match actual.match &&
92 - test_cmp expected.matchmore actual.matchmore
93 -'
94 -
79 test_expect_success 'treap sort' '
80 cat <<-\EOF >unsorted &&
81 68
test-string-pool.c deleted
-31
@@ -1,31 +0,0 @@
1 -/*
2 - * test-string-pool.c: code to exercise the svn importer's string pool
3 - */
4 -
5 -#include "git-compat-util.h"
6 -#include "vcs-svn/string_pool.h"
7 -
8 -int main(int argc, char *argv[])
9 -{
10 - const uint32_t unequal = pool_intern("does not equal");
11 - const uint32_t equal = pool_intern("equals");
12 - uint32_t buf[3];
13 - uint32_t n;
14 -
15 - if (argc != 2)
16 - usage("test-string-pool <string>,<string>");
17 -
18 - n = pool_tok_seq(3, buf, ",-", argv[1]);
19 - if (n >= 3)
20 - die("too many strings");
21 - if (n <= 1)
22 - die("too few strings");
23 -
24 - buf[2] = buf[1];
25 - buf[1] = (buf[0] == buf[2]) ? equal : unequal;
26 - pool_print_seq(3, buf, ' ', stdout);
27 - fputc('\n', stdout);
28 -
29 - pool_reset();
30 - return 0;
31 -}
vcs-svn/string_pool.c deleted
-113
@@ -1,113 +0,0 @@
1 -/*
2 - * Licensed under a two-clause BSD-style license.
3 - * See LICENSE for details.
4 - */
5 -
6 -#include "git-compat-util.h"
7 -#include "quote.h"
8 -#include "trp.h"
9 -#include "obj_pool.h"
10 -#include "string_pool.h"
11 -
12 -static struct trp_root tree = { ~0 };
13 -
14 -struct node {
15 - uint32_t offset;
16 - struct trp_node children;
17 -};
18 -
19 -/* Two memory pools: one for struct node, and another for strings */
20 -obj_pool_gen(node, struct node, 4096)
21 -obj_pool_gen(string, char, 4096)
22 -
23 -static char *node_value(struct node *node)
24 -{
25 - return node ? string_pointer(node->offset) : NULL;
26 -}
27 -
28 -static int node_cmp(struct node *a, struct node *b)
29 -{
30 - return strcmp(node_value(a), node_value(b));
31 -}
32 -
33 -/* Build a Treap from the node structure (a trp_node w/ offset) */
34 -trp_gen(static, tree_, struct node, children, node, node_cmp);
35 -
36 -const char *pool_fetch(uint32_t entry)
37 -{
38 - return node_value(node_pointer(entry));
39 -}
40 -
41 -uint32_t pool_intern(const char *key)
42 -{
43 - /* Canonicalize key */
44 - struct node *match = NULL, *node;
45 - uint32_t key_len;
46 - if (key == NULL)
47 - return ~0;
48 - key_len = strlen(key) + 1;
49 - node = node_pointer(node_alloc(1));
50 - node->offset = string_alloc(key_len);
51 - strcpy(node_value(node), key);
52 - match = tree_search(&tree, node);
53 - if (!match) {
54 - tree_insert(&tree, node);
55 - } else {
56 - node_free(1);
57 - string_free(key_len);
58 - node = match;
59 - }
60 - return node_offset(node);
61 -}
62 -
63 -uint32_t pool_tok_r(char *str, const char *delim, char **saveptr)
64 -{
65 - char *token = strtok_r(str, delim, saveptr);
66 - return token ? pool_intern(token) : ~0;
67 -}
68 -
69 -void pool_print_seq(uint32_t len, const uint32_t *seq, char delim, FILE *stream)
70 -{
71 - uint32_t i;
72 - for (i = 0; i < len && ~seq[i]; i++) {
73 - fputs(pool_fetch(seq[i]), stream);
74 - if (i < len - 1 && ~seq[i + 1])
75 - fputc(delim, stream);
76 - }
77 -}
78 -
79 -void pool_print_seq_q(uint32_t len, const uint32_t *seq, char delim, FILE *stream)
80 -{
81 - uint32_t i;
82 - for (i = 0; i < len && ~seq[i]; i++) {
83 - quote_c_style(pool_fetch(seq[i]), NULL, stream, 1);
84 - if (i < len - 1 && ~seq[i + 1])
85 - fputc(delim, stream);
86 - }
87 -}
88 -
89 -uint32_t pool_tok_seq(uint32_t sz, uint32_t *seq, const char *delim, char *str)
90 -{
91 - char *context = NULL;
92 - uint32_t token = ~0;
93 - uint32_t length;
94 -
95 - if (sz == 0)
96 - return ~0;
97 - if (str)
98 - token = pool_tok_r(str, delim, &context);
99 - for (length = 0; length < sz; length++) {
100 - seq[length] = token;
101 - if (token == ~0)
102 - return length;
103 - token = pool_tok_r(NULL, delim, &context);
104 - }
105 - seq[sz - 1] = ~0;
106 - return sz;
107 -}
108 -
109 -void pool_reset(void)
110 -{
111 - node_reset();
112 - string_reset();
113 -}
vcs-svn/string_pool.h deleted
-12
@@ -1,12 +0,0 @@
1 -#ifndef STRING_POOL_H_
2 -#define STRING_POOL_H_
3 -
4 -uint32_t pool_intern(const char *key);
5 -const char *pool_fetch(uint32_t entry);
6 -uint32_t pool_tok_r(char *str, const char *delim, char **saveptr);
7 -void pool_print_seq(uint32_t len, const uint32_t *seq, char delim, FILE *stream);
8 -void pool_print_seq_q(uint32_t len, const uint32_t *seq, char delim, FILE *stream);
9 -uint32_t pool_tok_seq(uint32_t sz, uint32_t *seq, const char *delim, char *str);
10 -void pool_reset(void);
11 -
12 -#endif
vcs-svn/string_pool.txt deleted
-43
@@ -1,43 +0,0 @@
1 -string_pool API
2 -===============
3 -
4 -The string_pool API provides facilities for replacing strings
5 -with integer keys that can be more easily compared and stored.
6 -The facilities are designed so that one could teach Git without
7 -too much trouble to store the information needed for these keys to
8 -remain valid over multiple executions.
9 -
10 -Functions
11 ----------
12 -
13 -pool_intern::
14 - Include a string in the string pool and get its key.
15 - If that string is already in the pool, retrieves its
16 - existing key.
17 -
18 -pool_fetch::
19 - Retrieve the string associated to a given key.
20 -
21 -pool_tok_r::
22 - Extract the key of the next token from a string.
23 - Interface mimics strtok_r.
24 -
25 -pool_print_seq::
26 - Print a sequence of strings named by key to a file, using the
27 - specified delimiter to separate them.
28 -
29 - If NULL (key ~0) appears in the sequence, the sequence ends
30 - early.
31 -
32 -pool_tok_seq::
33 - Split a string into tokens, storing the keys of segments
34 - into a caller-provided array.
35 -
36 - Unless sz is 0, the array will always be ~0-terminated.
37 - If there is not enough room for all the tokens, the
38 - array holds as many tokens as fit in the entries before
39 - the terminating ~0. Return value is the index after the
40 - last token, or sz if the tokens did not fit.
41 -
42 -pool_reset::
43 - Deallocate storage for the string pool.