mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Basic] Move copyCString to Basic/StringExtras.
Also, use StringRef.copy() instead of copyString().
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "swift/IDE/CodeCompletionCache.h"
|
||||
#include "swift/Basic/Cache.h"
|
||||
#include "swift/Basic/StringExtras.h"
|
||||
#include "llvm/ADT/APInt.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/Hashing.h"
|
||||
@@ -165,8 +166,11 @@ static bool readCachedModule(llvm::MemoryBuffer *in,
|
||||
}
|
||||
|
||||
const char *p = strings + index;
|
||||
auto size = read32le(p);
|
||||
auto str = copyString(*V.Allocator, StringRef(p, size));
|
||||
size_t size = read32le(p);
|
||||
StringRef str = StringRef(p, size);
|
||||
// Import the string to the allocator. Use null-terminated string to avoid
|
||||
// potential copies in clients.
|
||||
str = StringRef(copyCString(str, *V.Allocator), size);
|
||||
knownStrings[index] = str;
|
||||
return str;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user