|
36 | 36 | #include <initializer_list> |
37 | 37 | #include <memory> |
38 | 38 | #include <string> |
39 | | -#include <unordered_map> |
40 | | -#include <utility> |
41 | | -// We use c++14 std::experimental::string_view for optimizing hash computation |
42 | | -// only right now, its usage is limited in this file. Any broader usage of |
43 | | -// std::experiment in our core codebase is discouraged and needs community |
44 | | -// discussion for each use case. Reference for feature test macros of |
45 | | -// string_view: |
46 | | -// https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations |
47 | | -// https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros |
48 | | -#if defined(__cpp_lib_experimental_string_view) && __cpp_lib_experimental_string_view >= 201411 |
49 | | -#define TVM_USE_CXX14_STRING_VIEW_HASH 1 |
50 | | -#else |
51 | | -#define TVM_USE_CXX14_STRING_VIEW_HASH 0 |
52 | | -#endif |
53 | | - |
54 | | -// Tested with clang version 9.0.1 and c++17. It will detect string_view support |
55 | | -// correctly. |
56 | | -#if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606 |
57 | | -#define TVM_USE_CXX17_STRING_VIEW_HASH 1 |
58 | | -#else |
59 | | -#define TVM_USE_CXX17_STRING_VIEW_HASH 0 |
60 | | -#endif |
61 | | - |
62 | | -#if TVM_USE_CXX17_STRING_VIEW_HASH |
63 | 39 | #include <string_view> |
64 | | -#elif TVM_USE_CXX14_STRING_VIEW_HASH |
65 | | -#include <experimental/string_view> |
66 | | -#endif |
67 | | - |
68 | 40 | #include <type_traits> |
| 41 | +#include <unordered_map> |
69 | 42 | #include <utility> |
70 | 43 | #include <vector> |
71 | 44 |
|
@@ -277,13 +250,7 @@ class String : public ObjectRef { |
277 | 250 | static size_t HashBytes(const char* data, size_t size) { |
278 | 251 | // This function falls back to string copy with c++11 compiler and is |
279 | 252 | // recommended to be compiled with c++14 |
280 | | -#if TVM_USE_CXX17_STRING_VIEW_HASH |
281 | 253 | return std::hash<std::string_view>()(std::string_view(data, size)); |
282 | | -#elif TVM_USE_CXX14_STRING_VIEW_HASH |
283 | | - return std::hash<std::experimental::string_view>()(std::experimental::string_view(data, size)); |
284 | | -#else |
285 | | - return std::hash<std::string>()(std::string(data, size)); |
286 | | -#endif |
287 | 254 | } |
288 | 255 |
|
289 | 256 | TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(String, ObjectRef, StringObj); |
|
0 commit comments