mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
ADT: Use perfect forwarding in StringMapEntry::Create()
Now you can pass references into constructors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221946 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fb59c03af9
commit
4dc6aa2c17
@ -117,8 +117,9 @@ public:
|
||||
|
||||
explicit StringMapEntry(unsigned strLen)
|
||||
: StringMapEntryBase(strLen), second() {}
|
||||
StringMapEntry(unsigned strLen, ValueTy V)
|
||||
: StringMapEntryBase(strLen), second(std::move(V)) {}
|
||||
template <class InitTy>
|
||||
StringMapEntry(unsigned strLen, InitTy &&V)
|
||||
: StringMapEntryBase(strLen), second(std::forward<InitTy>(V)) {}
|
||||
|
||||
StringRef getKey() const {
|
||||
return StringRef(getKeyData(), getKeyLength());
|
||||
@ -138,10 +139,9 @@ public:
|
||||
|
||||
/// Create - Create a StringMapEntry for the specified key and default
|
||||
/// construct the value.
|
||||
template<typename AllocatorTy, typename InitType>
|
||||
static StringMapEntry *Create(StringRef Key,
|
||||
AllocatorTy &Allocator,
|
||||
InitType InitVal) {
|
||||
template <typename AllocatorTy, typename InitType>
|
||||
static StringMapEntry *Create(StringRef Key, AllocatorTy &Allocator,
|
||||
InitType &&InitVal) {
|
||||
unsigned KeyLength = Key.size();
|
||||
|
||||
// Allocate a new item with space for the string at the end and a null
|
||||
@ -154,7 +154,7 @@ public:
|
||||
static_cast<StringMapEntry*>(Allocator.Allocate(AllocSize,Alignment));
|
||||
|
||||
// Default construct the value.
|
||||
new (NewItem) StringMapEntry(KeyLength, std::move(InitVal));
|
||||
new (NewItem) StringMapEntry(KeyLength, std::forward<InitType>(InitVal));
|
||||
|
||||
// Copy the string information.
|
||||
char *StrBuffer = const_cast<char*>(NewItem->getKeyData());
|
||||
|
Loading…
Reference in New Issue
Block a user