krasimir created this revision. krasimir added a reviewer: bkramer. Herald added subscribers: cfe-commits, klimek. krasimir added subscribers: benhamilton, jolesiak.
This replaces an unordered_set from r322690 with an array and binary search. Repository: rC Clang https://reviews.llvm.org/D42189 Files: lib/Format/Format.cpp Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -41,25 +41,14 @@ #include <algorithm> #include <memory> #include <string> -#include <unordered_set> #define DEBUG_TYPE "format-formatter" using clang::format::FormatStyle; LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::IncludeCategory) LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::RawStringFormat) -namespace std { -// Allow using StringRef in std::unordered_set. -template <> struct hash<llvm::StringRef> { -public: - size_t operator()(const llvm::StringRef &s) const { - return llvm::hash_value(s); - } -}; -} // namespace std - namespace llvm { namespace yaml { template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> { @@ -1432,7 +1421,7 @@ private: static bool guessIsObjC(const SmallVectorImpl<AnnotatedLine *> &AnnotatedLines, const AdditionalKeywords &Keywords) { - static const std::unordered_set<StringRef> FoundationIdentifiers = { + static const llvm::ArrayRef<llvm::StringLiteral> FoundationIdentifiers = { "CGFloat", "NSAffineTransform", "NSArray", @@ -1490,8 +1479,9 @@ FormatTok->isOneOf(tok::numeric_constant, tok::l_square, tok::l_brace))) || (FormatTok->Tok.isAnyIdentifier() && - FoundationIdentifiers.find(FormatTok->TokenText) != - FoundationIdentifiers.end()) || + std::binary_search(FoundationIdentifiers.begin(), + FoundationIdentifiers.end(), + FormatTok->TokenText)) || FormatTok->is(TT_ObjCStringLiteral) || FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace, TT_ObjCBlockLParen,
Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -41,25 +41,14 @@ #include <algorithm> #include <memory> #include <string> -#include <unordered_set> #define DEBUG_TYPE "format-formatter" using clang::format::FormatStyle; LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::IncludeCategory) LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::RawStringFormat) -namespace std { -// Allow using StringRef in std::unordered_set. -template <> struct hash<llvm::StringRef> { -public: - size_t operator()(const llvm::StringRef &s) const { - return llvm::hash_value(s); - } -}; -} // namespace std - namespace llvm { namespace yaml { template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> { @@ -1432,7 +1421,7 @@ private: static bool guessIsObjC(const SmallVectorImpl<AnnotatedLine *> &AnnotatedLines, const AdditionalKeywords &Keywords) { - static const std::unordered_set<StringRef> FoundationIdentifiers = { + static const llvm::ArrayRef<llvm::StringLiteral> FoundationIdentifiers = { "CGFloat", "NSAffineTransform", "NSArray", @@ -1490,8 +1479,9 @@ FormatTok->isOneOf(tok::numeric_constant, tok::l_square, tok::l_brace))) || (FormatTok->Tok.isAnyIdentifier() && - FoundationIdentifiers.find(FormatTok->TokenText) != - FoundationIdentifiers.end()) || + std::binary_search(FoundationIdentifiers.begin(), + FoundationIdentifiers.end(), + FormatTok->TokenText)) || FormatTok->is(TT_ObjCStringLiteral) || FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace, TT_ObjCBlockLParen,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits