Skip to content

Commit b050f66

Browse files
authored
Merge pull request #3334 from compnerd/contains
2 parents 5ca61f6 + 081097e commit b050f66

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

lib/Basic/LangOptions.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,23 @@ static const StringRef SupportedConditionalCompilationEndianness[] = {
5050
"big"
5151
};
5252

53+
template <typename Type, size_t N>
54+
bool contains(const Type (&Array)[N], const Type &V) {
55+
return std::find(std::begin(Array), std::end(Array), V) != std::end(Array);
56+
}
57+
5358
bool LangOptions::isPlatformConditionOSSupported(StringRef OSName) {
54-
auto foundIt = std::find(std::begin(SupportedConditionalCompilationOSs),
55-
std::end(SupportedConditionalCompilationOSs),
56-
OSName);
57-
return foundIt != std::end(SupportedConditionalCompilationOSs);
59+
return contains(SupportedConditionalCompilationOSs, OSName);
5860
}
5961

6062
bool
6163
LangOptions::isPlatformConditionArchSupported(StringRef ArchName) {
62-
auto foundIt = std::find(std::begin(SupportedConditionalCompilationArches),
63-
std::end(SupportedConditionalCompilationArches),
64-
ArchName);
65-
return foundIt != std::end(SupportedConditionalCompilationArches);
64+
return contains(SupportedConditionalCompilationArches, ArchName);
6665
}
6766

6867
bool
6968
LangOptions::isPlatformConditionEndiannessSupported(StringRef Endianness) {
70-
auto foundIt = std::find(std::begin(SupportedConditionalCompilationEndianness),
71-
std::end(SupportedConditionalCompilationEndianness),
72-
Endianness);
73-
return foundIt != std::end(SupportedConditionalCompilationEndianness);
69+
return contains(SupportedConditionalCompilationEndianness, Endianness);
7470
}
7571

7672
StringRef

0 commit comments

Comments
 (0)