mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Provide move semantics for TinyPtrVector and for DenseMap's rehash function.
This makes DenseMap<..., TinyPtrVector<...>> as cheap as it always should've been! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157113 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f4c261b137
commit
ac5802bca0
@ -14,6 +14,7 @@
|
||||
#ifndef LLVM_ADT_DENSEMAP_H
|
||||
#define LLVM_ADT_DENSEMAP_H
|
||||
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Support/PointerLikeTypeTraits.h"
|
||||
#include "llvm/Support/type_traits.h"
|
||||
@ -438,8 +439,8 @@ private:
|
||||
bool FoundVal = LookupBucketFor(B->first, DestBucket);
|
||||
(void)FoundVal; // silence warning.
|
||||
assert(!FoundVal && "Key already in new map?");
|
||||
DestBucket->first = B->first;
|
||||
new (&DestBucket->second) ValueT(B->second);
|
||||
DestBucket->first = llvm_move(B->first);
|
||||
new (&DestBucket->second) ValueT(llvm_move(B->second));
|
||||
|
||||
// Free the value.
|
||||
B->second.~ValueT();
|
||||
|
@ -10,8 +10,10 @@
|
||||
#ifndef LLVM_ADT_TINYPTRVECTOR_H
|
||||
#define LLVM_ADT_TINYPTRVECTOR_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/PointerUnion.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -32,6 +34,11 @@ public:
|
||||
if (VecTy *V = Val.template dyn_cast<VecTy*>())
|
||||
Val = new VecTy(*V);
|
||||
}
|
||||
#if LLVM_USE_RVALUE_REFERENCES
|
||||
TinyPtrVector(TinyPtrVector &&RHS) : Val(RHS.Val) {
|
||||
RHS.Val = (EltTy)0;
|
||||
}
|
||||
#endif
|
||||
~TinyPtrVector() {
|
||||
if (VecTy *V = Val.template dyn_cast<VecTy*>())
|
||||
delete V;
|
||||
@ -159,6 +166,9 @@ public:
|
||||
|
||||
private:
|
||||
void operator=(const TinyPtrVector&); // NOT IMPLEMENTED YET.
|
||||
#if LLVM_USE_RVALUE_REFERENCES
|
||||
void operator=(TinyPtrVector&&); // NOT IMPLEMENTED YET.
|
||||
#endif
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user