Skip to content

Commit 1eec155

Browse files
committed
[ClangImporter] Adopt llvm::StringLiteral in CFTypeInfo.cpp
I didn't know this existed when I first wrote this code. No functionality change.
1 parent f4718be commit 1eec155

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

Diff for: lib/ClangImporter/CFTypeInfo.cpp

+2-18
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,7 @@
2020
using namespace swift;
2121
using namespace importer;
2222

23-
/// The maximum length of any particular string in the list of known CF types.
24-
const size_t MaxCFTypeNameLength = 38;
2523
namespace {
26-
// FIXME: This is only needed because llvm::StringRef doesn't have a constexpr
27-
// constructor.
28-
struct CFTypeListEntry {
29-
unsigned char Length;
30-
char Data[MaxCFTypeNameLength + 1];
31-
32-
operator StringRef() const { return StringRef(Data, Length); }
33-
};
34-
3524
// Quasi-lexicographic order: string length first, then string data.
3625
// Since we don't care about the actual length, we can use this, which
3726
// lets us ignore the string data a larger proportion of the time.
@@ -43,16 +32,11 @@ namespace {
4332
};
4433
} // end anonymous namespace
4534

46-
template <size_t Len>
47-
static constexpr size_t string_lengthof(const char (&data)[Len]) {
48-
return Len - 1;
49-
}
50-
5135
/// The list of known CF types. We use 'constexpr' to verify that this is
5236
/// emitted as a constant. Note that this is expected to be sorted in
5337
/// quasi-lexicographic order.
54-
static constexpr const CFTypeListEntry KnownCFTypes[] = {
55-
#define CF_TYPE(NAME) { string_lengthof(#NAME), #NAME },
38+
static constexpr const llvm::StringLiteral KnownCFTypes[] = {
39+
#define CF_TYPE(NAME) #NAME,
5640
#define NON_CF_TYPE(NAME)
5741
#include "SortedCFDatabase.def"
5842
};

0 commit comments

Comments
 (0)