SmallMap, FlatArrayMap::copyFrom

Replaced memcpy with std::copy, since the first one may work improperly with non POD data.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158457 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Stepan Dyatkovskiy 2012-06-14 16:59:43 +00:00
parent 722f2544b2
commit cba91230c0

View File

@ -96,11 +96,13 @@ namespace llvm {
void copyFrom(const self &RHS) {
memcpy(Array, RHS.Array, sizeof(value_type) * (MaxArraySize + 1));
std::copy(RHS.Array, RHS.Array + MaxArraySize + 1, Array);
NumElements = RHS.NumElements;
}
void init () {
// Even if Array contains non POD, use memset for last element,
// since it is used as end() iterator only.
memset(Array + MaxArraySize, 0, sizeof(value_type));
NumElements = 0;
}