Commit c6ed744e by Evan Brown Committed by Copybara-Service

Roll back extern template instatiations in swisstable due to binary size…

Roll back extern template instatiations in swisstable due to binary size increases in shared libraries.

PiperOrigin-RevId: 615497725
Change-Id: Ic29db8923ea4ea7cd0b01b396896fa9fff8c74b0
parent e4b07ec1
...@@ -68,9 +68,7 @@ set(ABSL_INTERNAL_DLL_FILES ...@@ -68,9 +68,7 @@ set(ABSL_INTERNAL_DLL_FILES
"container/btree_set.h" "container/btree_set.h"
"container/fixed_array.h" "container/fixed_array.h"
"container/flat_hash_map.h" "container/flat_hash_map.h"
"container/flat_hash_map.cc"
"container/flat_hash_set.h" "container/flat_hash_set.h"
"container/flat_hash_set.cc"
"container/inlined_vector.h" "container/inlined_vector.h"
"container/internal/btree.h" "container/internal/btree.h"
"container/internal/btree_container.h" "container/internal/btree_container.h"
...@@ -93,9 +91,7 @@ set(ABSL_INTERNAL_DLL_FILES ...@@ -93,9 +91,7 @@ set(ABSL_INTERNAL_DLL_FILES
"container/internal/raw_hash_set.h" "container/internal/raw_hash_set.h"
"container/internal/tracked.h" "container/internal/tracked.h"
"container/node_hash_map.h" "container/node_hash_map.h"
"container/node_hash_map.cc"
"container/node_hash_set.h" "container/node_hash_set.h"
"container/node_hash_set.cc"
"crc/crc32c.cc" "crc/crc32c.cc"
"crc/crc32c.h" "crc/crc32c.h"
"crc/internal/cpu_detect.cc" "crc/internal/cpu_detect.cc"
......
...@@ -242,7 +242,6 @@ NOTEST_TAGS_MOBILE = [ ...@@ -242,7 +242,6 @@ NOTEST_TAGS_MOBILE = [
cc_library( cc_library(
name = "flat_hash_map", name = "flat_hash_map",
srcs = ["flat_hash_map.cc"],
hdrs = ["flat_hash_map.h"], hdrs = ["flat_hash_map.h"],
copts = ABSL_DEFAULT_COPTS, copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS, linkopts = ABSL_DEFAULT_LINKOPTS,
...@@ -250,9 +249,7 @@ cc_library( ...@@ -250,9 +249,7 @@ cc_library(
":container_memory", ":container_memory",
":hash_function_defaults", ":hash_function_defaults",
":raw_hash_map", ":raw_hash_map",
":raw_hash_set",
"//absl/algorithm:container", "//absl/algorithm:container",
"//absl/base:config",
"//absl/base:core_headers", "//absl/base:core_headers",
"//absl/memory", "//absl/memory",
], ],
...@@ -282,7 +279,6 @@ cc_test( ...@@ -282,7 +279,6 @@ cc_test(
cc_library( cc_library(
name = "flat_hash_set", name = "flat_hash_set",
srcs = ["flat_hash_set.cc"],
hdrs = ["flat_hash_set.h"], hdrs = ["flat_hash_set.h"],
copts = ABSL_DEFAULT_COPTS, copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS, linkopts = ABSL_DEFAULT_LINKOPTS,
...@@ -291,7 +287,6 @@ cc_library( ...@@ -291,7 +287,6 @@ cc_library(
":hash_function_defaults", ":hash_function_defaults",
":raw_hash_set", ":raw_hash_set",
"//absl/algorithm:container", "//absl/algorithm:container",
"//absl/base:config",
"//absl/base:core_headers", "//absl/base:core_headers",
"//absl/memory", "//absl/memory",
], ],
...@@ -323,7 +318,6 @@ cc_test( ...@@ -323,7 +318,6 @@ cc_test(
cc_library( cc_library(
name = "node_hash_map", name = "node_hash_map",
srcs = ["node_hash_map.cc"],
hdrs = ["node_hash_map.h"], hdrs = ["node_hash_map.h"],
copts = ABSL_DEFAULT_COPTS, copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS, linkopts = ABSL_DEFAULT_LINKOPTS,
...@@ -332,9 +326,7 @@ cc_library( ...@@ -332,9 +326,7 @@ cc_library(
":hash_function_defaults", ":hash_function_defaults",
":node_slot_policy", ":node_slot_policy",
":raw_hash_map", ":raw_hash_map",
":raw_hash_set",
"//absl/algorithm:container", "//absl/algorithm:container",
"//absl/base:config",
"//absl/base:core_headers", "//absl/base:core_headers",
"//absl/memory", "//absl/memory",
], ],
...@@ -361,7 +353,6 @@ cc_test( ...@@ -361,7 +353,6 @@ cc_test(
cc_library( cc_library(
name = "node_hash_set", name = "node_hash_set",
srcs = ["node_hash_set.cc"],
hdrs = ["node_hash_set.h"], hdrs = ["node_hash_set.h"],
copts = ABSL_DEFAULT_COPTS, copts = ABSL_DEFAULT_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS, linkopts = ABSL_DEFAULT_LINKOPTS,
...@@ -371,7 +362,6 @@ cc_library( ...@@ -371,7 +362,6 @@ cc_library(
":node_slot_policy", ":node_slot_policy",
":raw_hash_set", ":raw_hash_set",
"//absl/algorithm:container", "//absl/algorithm:container",
"//absl/base:config",
"//absl/base:core_headers", "//absl/base:core_headers",
"//absl/memory", "//absl/memory",
], ],
......
...@@ -283,17 +283,13 @@ absl_cc_library( ...@@ -283,17 +283,13 @@ absl_cc_library(
flat_hash_map flat_hash_map
HDRS HDRS
"flat_hash_map.h" "flat_hash_map.h"
SRCS
"flat_hash_map.cc"
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_DEFAULT_COPTS}
DEPS DEPS
absl::config
absl::container_memory absl::container_memory
absl::core_headers absl::core_headers
absl::hash_function_defaults absl::hash_function_defaults
absl::raw_hash_map absl::raw_hash_map
absl::raw_hash_set
absl::algorithm_container absl::algorithm_container
absl::memory absl::memory
PUBLIC PUBLIC
...@@ -325,12 +321,9 @@ absl_cc_library( ...@@ -325,12 +321,9 @@ absl_cc_library(
flat_hash_set flat_hash_set
HDRS HDRS
"flat_hash_set.h" "flat_hash_set.h"
SRCS
"flat_hash_set.cc"
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_DEFAULT_COPTS}
DEPS DEPS
absl::config
absl::container_memory absl::container_memory
absl::hash_function_defaults absl::hash_function_defaults
absl::raw_hash_set absl::raw_hash_set
...@@ -369,18 +362,14 @@ absl_cc_library( ...@@ -369,18 +362,14 @@ absl_cc_library(
node_hash_map node_hash_map
HDRS HDRS
"node_hash_map.h" "node_hash_map.h"
SRCS
"node_hash_map.cc"
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_DEFAULT_COPTS}
DEPS DEPS
absl::config
absl::container_memory absl::container_memory
absl::core_headers absl::core_headers
absl::hash_function_defaults absl::hash_function_defaults
absl::node_slot_policy absl::node_slot_policy
absl::raw_hash_map absl::raw_hash_map
absl::raw_hash_set
absl::algorithm_container absl::algorithm_container
absl::memory absl::memory
PUBLIC PUBLIC
...@@ -409,12 +398,9 @@ absl_cc_library( ...@@ -409,12 +398,9 @@ absl_cc_library(
node_hash_set node_hash_set
HDRS HDRS
"node_hash_set.h" "node_hash_set.h"
SRCS
"node_hash_set.cc"
COPTS COPTS
${ABSL_DEFAULT_COPTS} ${ABSL_DEFAULT_COPTS}
DEPS DEPS
absl::config
absl::container_memory absl::container_memory
absl::core_headers absl::core_headers
absl::hash_function_defaults absl::hash_function_defaults
......
// Copyright 2024 The Abseil Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "absl/container/flat_hash_map.h"
#include <cstdint>
#include <string>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, int32_t, int32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, std::string, int32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, int32_t, std::string);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, int64_t, int64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, std::string, int64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, int64_t, std::string);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, uint32_t, uint32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, std::string, uint32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, uint32_t, std::string);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, uint64_t, uint64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, std::string, uint64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, uint64_t, std::string);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(template, std::string, std::string);
ABSL_NAMESPACE_END
} // namespace absl
...@@ -31,20 +31,15 @@ ...@@ -31,20 +31,15 @@
#define ABSL_CONTAINER_FLAT_HASH_MAP_H_ #define ABSL_CONTAINER_FLAT_HASH_MAP_H_
#include <cstddef> #include <cstddef>
#include <cstdint>
#include <memory>
#include <new> #include <new>
#include <string>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "absl/base/config.h"
#include "absl/base/macros.h" #include "absl/base/macros.h"
#include "absl/container/internal/container_memory.h" #include "absl/container/internal/container_memory.h"
#include "absl/container/internal/hash_function_defaults.h" // IWYU pragma: export #include "absl/container/internal/hash_function_defaults.h" // IWYU pragma: export
#include "absl/container/internal/raw_hash_map.h" // IWYU pragma: export #include "absl/container/internal/raw_hash_map.h" // IWYU pragma: export
#include "absl/container/internal/raw_hash_set.h" // IWYU pragma: export
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
namespace absl { namespace absl {
...@@ -637,42 +632,6 @@ struct IsUnorderedContainer< ...@@ -637,42 +632,6 @@ struct IsUnorderedContainer<
} // namespace container_algorithm_internal } // namespace container_algorithm_internal
// Explicit template instantiations for common map types in order to decrease
// linker input size. Note that explicitly instantiating flat_hash_map itself
// doesn't help because it has no non-alias members. If we need to decrease
// linker input size more, we could potentially (a) add more key/value types,
// e.g. string_view/Cord, (b) instantiate some template member functions, e.g.
// operator[]/find. The EXTERN argument is `extern` for the declaration and
// empty for the definition.
#define ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(TEMPLATE, KEY, VALUE) \
TEMPLATE class absl::container_internal::raw_hash_map< \
absl::container_internal::FlatHashMapPolicy<KEY, VALUE>, \
absl::container_internal::hash_default_hash<KEY>, \
absl::container_internal::hash_default_eq<KEY>, \
std::allocator<std::pair<const KEY, VALUE>>>; \
TEMPLATE class absl::container_internal::raw_hash_set< \
absl::container_internal::FlatHashMapPolicy<KEY, VALUE>, \
absl::container_internal::hash_default_hash<KEY>, \
absl::container_internal::hash_default_eq<KEY>, \
std::allocator<std::pair<const KEY, VALUE>>>;
// We use exact-width integer types rather than `int`/`long`/`long long` because
// these are the types recommended in the Google C++ style guide and which are
// commonly used in Google code.
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, int32_t, int32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, std::string, int32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, int32_t, std::string);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, int64_t, int64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, std::string, int64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, int64_t, std::string);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, uint32_t, uint32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, std::string, uint32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, uint32_t, std::string);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, uint64_t, uint64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, std::string, uint64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, uint64_t, std::string);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_MAP(extern template, std::string, std::string);
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
......
// Copyright 2024 The Abseil Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "absl/container/flat_hash_set.h"
#include <cstdint>
#include <string>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(template, int8_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(template, int16_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(template, int32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(template, int64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(template, uint8_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(template, uint16_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(template, uint32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(template, uint64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(template, std::string);
ABSL_NAMESPACE_END
} // namespace absl
...@@ -30,14 +30,11 @@ ...@@ -30,14 +30,11 @@
#define ABSL_CONTAINER_FLAT_HASH_SET_H_ #define ABSL_CONTAINER_FLAT_HASH_SET_H_
#include <cstddef> #include <cstddef>
#include <cstdint>
#include <memory> #include <memory>
#include <string>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "absl/base/config.h"
#include "absl/base/macros.h" #include "absl/base/macros.h"
#include "absl/container/internal/container_memory.h" #include "absl/container/internal/container_memory.h"
#include "absl/container/internal/hash_function_defaults.h" // IWYU pragma: export #include "absl/container/internal/hash_function_defaults.h" // IWYU pragma: export
...@@ -526,32 +523,6 @@ struct IsUnorderedContainer<absl::flat_hash_set<Key, Hash, KeyEqual, Allocator>> ...@@ -526,32 +523,6 @@ struct IsUnorderedContainer<absl::flat_hash_set<Key, Hash, KeyEqual, Allocator>>
} // namespace container_algorithm_internal } // namespace container_algorithm_internal
// Explicit template instantiations for common set types in order to decrease
// linker input size. Note that explicitly instantiating flat_hash_set itself
// doesn't help because it has no non-alias members. If we need to decrease
// linker input size more, we could potentially (a) add more key types, e.g.
// string_view/Cord, (b) instantiate some template member functions, e.g.
// find/insert/emplace. The EXTERN argument is `extern` for the declaration and
// empty for the definition.
#define ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(TEMPLATE, KEY) \
TEMPLATE class absl::container_internal::raw_hash_set< \
absl::container_internal::FlatHashSetPolicy<KEY>, \
absl::container_internal::hash_default_hash<KEY>, \
absl::container_internal::hash_default_eq<KEY>, std::allocator<KEY>>;
// We use exact-width integer types rather than `int`/`long`/`long long` because
// these are the types recommended in the Google C++ style guide and which are
// commonly used in Google code.
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(extern template, int8_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(extern template, int16_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(extern template, int32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(extern template, int64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(extern template, uint8_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(extern template, uint16_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(extern template, uint32_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(extern template, uint64_t);
ABSL_INTERNAL_TEMPLATE_FLAT_HASH_SET(extern template, std::string);
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
......
...@@ -1839,7 +1839,7 @@ class HashSetResizeHelper { ...@@ -1839,7 +1839,7 @@ class HashSetResizeHelper {
// Reads `capacity` and updates all other fields based on the result of // Reads `capacity` and updates all other fields based on the result of
// the allocation. // the allocation.
// //
// It also may do the following actions: // It also may do the folowing actions:
// 1. initialize control bytes // 1. initialize control bytes
// 2. initialize slots // 2. initialize slots
// 3. deallocate old slots. // 3. deallocate old slots.
...@@ -2204,14 +2204,9 @@ class raw_hash_set { ...@@ -2204,14 +2204,9 @@ class raw_hash_set {
bool is_soo() const { return fits_in_soo(capacity()); } bool is_soo() const { return fits_in_soo(capacity()); }
bool is_full_soo() const { return is_soo() && !empty(); } bool is_full_soo() const { return is_soo() && !empty(); }
// Give an early error when key_type is not hashable/eq. Definitions are // Give an early error when key_type is not hashable/eq.
// provided because otherwise explicit template instantiation fails on MSVC. auto KeyTypeCanBeHashed(const Hash& h, const key_type& k) -> decltype(h(k));
auto KeyTypeCanBeHashed(const Hash& h, const key_type& k) -> decltype(h(k)) { auto KeyTypeCanBeEq(const Eq& eq, const key_type& k) -> decltype(eq(k, k));
ABSL_UNREACHABLE();
}
auto KeyTypeCanBeEq(const Eq& eq, const key_type& k) -> decltype(eq(k, k)) {
ABSL_UNREACHABLE();
}
using AllocTraits = absl::allocator_traits<allocator_type>; using AllocTraits = absl::allocator_traits<allocator_type>;
using SlotAlloc = typename absl::allocator_traits< using SlotAlloc = typename absl::allocator_traits<
...@@ -2400,18 +2395,7 @@ class raw_hash_set { ...@@ -2400,18 +2395,7 @@ class raw_hash_set {
const_iterator operator++(int) { return inner_++; } const_iterator operator++(int) { return inner_++; }
friend bool operator==(const const_iterator& a, const const_iterator& b) { friend bool operator==(const const_iterator& a, const const_iterator& b) {
// Suppress erroneous uninitialized memory errors on GCC. This seems to be
// because the slot pointer in the inner_ iterator is uninitialized, even
// though that pointer is not used when uninitialized.
// Similar bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112637.
#if !defined(__clang__) && defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
return a.inner_ == b.inner_; return a.inner_ == b.inner_;
#if !defined(__clang__) && defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
} }
friend bool operator!=(const const_iterator& a, const const_iterator& b) { friend bool operator!=(const const_iterator& a, const const_iterator& b) {
return !(a == b); return !(a == b);
...@@ -3735,9 +3719,7 @@ class raw_hash_set { ...@@ -3735,9 +3719,7 @@ class raw_hash_set {
return const_cast<raw_hash_set*>(this)->iterator_at(i); return const_cast<raw_hash_set*>(this)->iterator_at(i);
} }
reference unchecked_deref(iterator it) { reference unchecked_deref(iterator it) { return it.unchecked_deref(); }
return const_cast<reference>(it.unchecked_deref());
}
private: private:
friend struct RawHashSetTestOnlyAccess; friend struct RawHashSetTestOnlyAccess;
...@@ -3787,13 +3769,13 @@ class raw_hash_set { ...@@ -3787,13 +3769,13 @@ class raw_hash_set {
return static_cast<slot_type*>(common().soo_data()); return static_cast<slot_type*>(common().soo_data());
} }
const slot_type* soo_slot() const { const slot_type* soo_slot() const {
return const_cast<raw_hash_set*>(this)->soo_slot(); return reinterpret_cast<raw_hash_set*>(this)->soo_slot();
} }
iterator soo_iterator() { iterator soo_iterator() {
return {SooControl(), soo_slot(), common().generation_ptr()}; return {SooControl(), soo_slot(), common().generation_ptr()};
} }
const_iterator soo_iterator() const { const_iterator soo_iterator() const {
return const_cast<raw_hash_set*>(this)->soo_iterator(); return reinterpret_cast<raw_hash_set*>(this)->soo_iterator();
} }
HashtablezInfoHandle infoz() { HashtablezInfoHandle infoz() {
assert(!is_soo()); assert(!is_soo());
......
// Copyright 2024 The Abseil Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "absl/container/node_hash_map.h"
#include <cstdint>
#include <string>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, int32_t, int32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, std::string, int32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, int32_t, std::string);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, int64_t, int64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, std::string, int64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, int64_t, std::string);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, uint32_t, uint32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, std::string, uint32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, uint32_t, std::string);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, uint64_t, uint64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, std::string, uint64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, uint64_t, std::string);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(template, std::string, std::string);
ABSL_NAMESPACE_END
} // namespace absl
...@@ -37,15 +37,11 @@ ...@@ -37,15 +37,11 @@
#define ABSL_CONTAINER_NODE_HASH_MAP_H_ #define ABSL_CONTAINER_NODE_HASH_MAP_H_
#include <cstddef> #include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "absl/base/config.h"
#include "absl/base/macros.h" #include "absl/base/macros.h"
#include "absl/container/internal/container_memory.h" #include "absl/container/internal/container_memory.h"
#include "absl/container/internal/hash_function_defaults.h" // IWYU pragma: export #include "absl/container/internal/hash_function_defaults.h" // IWYU pragma: export
...@@ -627,42 +623,6 @@ struct IsUnorderedContainer< ...@@ -627,42 +623,6 @@ struct IsUnorderedContainer<
} // namespace container_algorithm_internal } // namespace container_algorithm_internal
// Explicit template instantiations for common map types in order to decrease
// linker input size. Note that explicitly instantiating node_hash_map itself
// doesn't help because it has no non-alias members. If we need to decrease
// linker input size more, we could potentially (a) add more key/value types,
// e.g. string_view/Cord, (b) instantiate some template member functions, e.g.
// operator[]/find. The EXTERN argument is `extern` for the declaration and
// empty for the definition.
#define ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(TEMPLATE, KEY, VALUE) \
TEMPLATE class absl::container_internal::raw_hash_map< \
absl::container_internal::NodeHashMapPolicy<KEY, VALUE>, \
absl::container_internal::hash_default_hash<KEY>, \
absl::container_internal::hash_default_eq<KEY>, \
std::allocator<std::pair<const KEY, VALUE>>>; \
TEMPLATE class absl::container_internal::raw_hash_set< \
absl::container_internal::NodeHashMapPolicy<KEY, VALUE>, \
absl::container_internal::hash_default_hash<KEY>, \
absl::container_internal::hash_default_eq<KEY>, \
std::allocator<std::pair<const KEY, VALUE>>>;
// We use exact-width integer types rather than `int`/`long`/`long long` because
// these are the types recommended in the Google C++ style guide and which are
// commonly used in Google code.
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, int32_t, int32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, std::string, int32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, int32_t, std::string);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, int64_t, int64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, std::string, int64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, int64_t, std::string);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, uint32_t, uint32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, std::string, uint32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, uint32_t, std::string);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, uint64_t, uint64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, std::string, uint64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, uint64_t, std::string);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_MAP(extern template, std::string, std::string);
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
......
// Copyright 2024 The Abseil Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "absl/container/node_hash_set.h"
#include <cstdint>
#include <string>
#include "absl/base/config.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(template, int8_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(template, int16_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(template, int32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(template, int64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(template, uint8_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(template, uint16_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(template, uint32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(template, uint64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(template, std::string);
ABSL_NAMESPACE_END
} // namespace absl
...@@ -36,13 +36,9 @@ ...@@ -36,13 +36,9 @@
#define ABSL_CONTAINER_NODE_HASH_SET_H_ #define ABSL_CONTAINER_NODE_HASH_SET_H_
#include <cstddef> #include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <type_traits> #include <type_traits>
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "absl/base/config.h"
#include "absl/base/macros.h" #include "absl/base/macros.h"
#include "absl/container/internal/container_memory.h" #include "absl/container/internal/container_memory.h"
#include "absl/container/internal/hash_function_defaults.h" // IWYU pragma: export #include "absl/container/internal/hash_function_defaults.h" // IWYU pragma: export
...@@ -522,32 +518,6 @@ struct IsUnorderedContainer<absl::node_hash_set<Key, Hash, KeyEqual, Allocator>> ...@@ -522,32 +518,6 @@ struct IsUnorderedContainer<absl::node_hash_set<Key, Hash, KeyEqual, Allocator>>
: std::true_type {}; : std::true_type {};
} // namespace container_algorithm_internal } // namespace container_algorithm_internal
// Explicit template instantiations for common set types in order to decrease
// linker input size. Note that explicitly instantiating node_hash_set itself
// doesn't help because it has no non-alias members. If we need to decrease
// linker input size more, we could potentially (a) add more key types, e.g.
// string_view/Cord, (b) instantiate some template member functions, e.g.
// find/insert/emplace.
#define ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(TEMPLATE, KEY) \
TEMPLATE class absl::container_internal::raw_hash_set< \
absl::container_internal::NodeHashSetPolicy<KEY>, \
absl::container_internal::hash_default_hash<KEY>, \
absl::container_internal::hash_default_eq<KEY>, std::allocator<KEY>>;
// We use exact-width integer types rather than `int`/`long`/`long long` because
// these are the types recommended in the Google C++ style guide and which are
// commonly used in Google code.
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(extern template, int8_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(extern template, int16_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(extern template, int32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(extern template, int64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(extern template, uint8_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(extern template, uint16_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(extern template, uint32_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(extern template, uint64_t);
ABSL_INTERNAL_TEMPLATE_NODE_HASH_SET(extern template, std::string);
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment