From 15de0952a42547155457636060982760fa443c18 Mon Sep 17 00:00:00 2001
From: Nathan Sashihara <[email protected]>
Date: Wed, 26 Aug 2020 09:12:04 -0700
Subject: [PATCH] Fix: khash with string key not compiling with dmd if inlining
enabled
Added a build type to dub.json that can be used to test this:
dub test --compiler=dmd --build=unittest-inline
---
dub.json | 5 +++++
source/dklib/khash.d | 39 +++++++++++++++++++++------------------
2 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/dub.json b/dub.json
index c6b4901..a19e755 100644
--- a/dub.json
+++ b/dub.json
@@ -6,5 +6,10 @@
"license": "MIT",
"dependencies": {
},
+ "buildTypes": {
+ "unittest-inline": {
+ "buildOptions": ["unittests", "optimize", "inline"]
+ }
+ },
"excludedSourceFiles": ["source/dklib/benchmark_khash.d"]
}
diff --git a/source/dklib/khash.d b/source/dklib/khash.d
index e9d8fdd..2c564c7 100644
--- a/source/dklib/khash.d
+++ b/source/dklib/khash.d
@@ -471,13 +471,6 @@ pragma(inline, true)
return cast(khint32_t) ((key)>>33^(key)^(key)<<11);
}
- khint_t __ac_X31_hash_string(const(char)* s)
- {
- khint_t h = cast(khint_t)*s;
- if (h) for (++s; *s; ++s) h = (h << 5) - h + cast(khint_t)*s;
- return h;
- }
-
auto kh_hash_func(T)(T* key)
if(is(T == char) || is(T == const(char)) || is(T == immutable(char)))
{
@@ -490,17 +483,6 @@ pragma(inline, true)
return (strcmp(a, b) == 0);
}
- auto kh_hash_func(T)(T key)
- if(isSomeString!T)
- {
- // rewrite __ac_X31_hash_string for D string/smart array
- if (key.length == 0) return 0;
- khint_t h = key[0];
- for (int i=1; i