diff options
author | Martin Probst <martin@probst.io> | 2016-07-09 15:11:18 +0000 |
---|---|---|
committer | Martin Probst <martin@probst.io> | 2016-07-09 15:11:18 +0000 |
commit | 3d1d8197d5a0c2e9e0b9d6da0b77f375c2062b2b (patch) | |
tree | 7571d5102e8b834f5cc64c8819841fd8f09fdb3e /lib/Format/SortJavaScriptImports.cpp | |
parent | 3c9460b0d41b8e1953dca467d9d0031c1d7f3976 (diff) |
clang-format: [JS] Sort imports case insensitive.
Summary: ASCII case sorting does not help finding imported symbols quickly, and it is common to have e.g. class Foo and function fooFactory exported/imported from the same file.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D22146
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/SortJavaScriptImports.cpp')
-rw-r--r-- | lib/Format/SortJavaScriptImports.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Format/SortJavaScriptImports.cpp b/lib/Format/SortJavaScriptImports.cpp index 8010e4914f..32d5d756a3 100644 --- a/lib/Format/SortJavaScriptImports.cpp +++ b/lib/Format/SortJavaScriptImports.cpp @@ -105,8 +105,8 @@ bool operator<(const JsModuleReference &LHS, const JsModuleReference &RHS) { // Empty URLs sort *last* (for export {...};). if (LHS.URL.empty() != RHS.URL.empty()) return LHS.URL.empty() < RHS.URL.empty(); - if (LHS.URL != RHS.URL) - return LHS.URL < RHS.URL; + if (int Res = LHS.URL.compare_lower(RHS.URL)) + return Res < 0; // '*' imports (with prefix) sort before {a, b, ...} imports. if (LHS.Prefix.empty() != RHS.Prefix.empty()) return LHS.Prefix.empty() < RHS.Prefix.empty(); @@ -245,7 +245,7 @@ private: std::stable_sort( Symbols.begin(), Symbols.end(), [&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) { - return LHS.Symbol < RHS.Symbol; + return LHS.Symbol.compare_lower(RHS.Symbol) < 0; }); if (Symbols == Reference.Symbols) { // No change in symbol order. |