hashmap: add string interning API
authorKarsten Blees <karsten.blees@gmail.com>
Wed, 2 Jul 2014 22:22:54 +0000 (00:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Jul 2014 20:56:38 +0000 (13:56 -0700)
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>
No differences found