Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarsten Blees <karsten.blees@gmail.com>2014-07-03 02:22:54 +0400
committerJunio C Hamano <gitster@pobox.com>2014-07-08 00:56:38 +0400
commit7b64d42d22206d9995a8f0cb3b515e623cac4702 (patch)
tree26895c5fde113b1d84f52409f951feb37f451412 /t/t0011-hashmap.sh
parentab73a9d119240b0b908ccb9edd19b8e536ce29b9 (diff)
hashmap: add string interning API
Interning short strings with high probability of duplicates can reduce the memory footprint and speed up comparisons. Add strintern() and memintern() APIs that use a hashmap to manage the pool of unique, interned strings. Note: strintern(getenv()) could be used to sanitize git's use of getenv(), in case we ever encounter a platform where a call to getenv() invalidates previous getenv() results (which is allowed by POSIX). Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0011-hashmap.sh')
-rwxr-xr-xt/t0011-hashmap.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t0011-hashmap.sh b/t/t0011-hashmap.sh
index 391e2b6492..f97c80556f 100755
--- a/t/t0011-hashmap.sh
+++ b/t/t0011-hashmap.sh
@@ -237,4 +237,17 @@ test_expect_success 'grow / shrink' '
'
+test_expect_success 'string interning' '
+
+test_hashmap "intern value1
+intern Value1
+intern value2
+intern value2
+" "value1
+Value1
+value2
+value2"
+
+'
+
test_done