mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8375544: JfrSet::clear should not use memset
Reviewed-by: mgronlun
This commit is contained in:
parent
4c9103f7b6
commit
3033e6f421
@ -26,6 +26,7 @@
|
||||
#define SHARE_JFR_UTILITIES_JFRSET_HPP
|
||||
|
||||
#include "cppstdlib/new.hpp"
|
||||
#include "cppstdlib/type_traits.hpp"
|
||||
#include "jfr/utilities/jfrTypes.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
|
||||
@ -110,7 +111,14 @@ class JfrSetStorage : public AnyObj {
|
||||
}
|
||||
|
||||
void clear() {
|
||||
memset(_table, 0, _table_size * sizeof(K));
|
||||
for (unsigned i = 0; i < _table_size; ++i) {
|
||||
if constexpr (std::is_copy_assignable_v<K>) {
|
||||
_table[i] = K{};
|
||||
} else {
|
||||
_table[i].~K();
|
||||
::new (&_table[i]) K{};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user