mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 06:24:57 +00:00
Make the copy member of StringRef/ArrayRef generic wrt allocators.
Doesn't make sense to restrict this to BumpPtrAllocator. While there replace an explicit loop with std::equal. Some standard libraries know how to compile this down to a ::memcmp call if possible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206615 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -10,7 +10,6 @@
|
||||
#ifndef LLVM_ADT_STRINGREF_H
|
||||
#define LLVM_ADT_STRINGREF_H
|
||||
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
@ -124,9 +123,9 @@ namespace llvm {
|
||||
return Data[Length-1];
|
||||
}
|
||||
|
||||
// copy - Allocate copy in BumpPtrAllocator and return StringRef to it.
|
||||
StringRef copy(BumpPtrAllocator &Allocator) {
|
||||
char *S = Allocator.Allocate<char>(Length);
|
||||
// copy - Allocate copy in Allocator and return StringRef to it.
|
||||
template <typename Allocator> StringRef copy(Allocator &A) {
|
||||
char *S = A.template Allocate<char>(Length);
|
||||
std::copy(begin(), end(), S);
|
||||
return StringRef(S, Length);
|
||||
}
|
||||
|
Reference in New Issue
Block a user