[llvm] [ADT] Skip destroying trivially destructible values in DenseMap (PR #106934)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 1 18:46:37 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/106934
None
>From 4f7d10745202e23006dfe59e9998220371c1ec18 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 1 Sep 2024 10:37:52 -0700
Subject: [PATCH] [ADT] Skip destroying trivially destructible values in
DenseMap
---
llvm/include/llvm/ADT/DenseMap.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index f71cd5b4771b75..68f3f1defc2bd0 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -392,6 +392,11 @@ class DenseMapBase : public DebugEpochBase {
DenseMapBase() = default;
void destroyAll() {
+ // Don't bother destroying trivially destructible stuff.
+ if constexpr (std::is_trivially_destructible_v<KeyT> &&
+ std::is_trivially_destructible_v<ValueT>)
+ return;
+
if (getNumBuckets() == 0) // Nothing to do.
return;
More information about the llvm-commits
mailing list