[clangd] Fix MSVC compile error, attempt 2
authorKadir Cetinkaya <kadircet@google.com>
Wed, 15 Apr 2020 07:33:12 +0000 (09:33 +0200)
committerKadir Cetinkaya <kadircet@google.com>
Wed, 15 Apr 2020 07:33:12 +0000 (09:33 +0200)
clang-tools-extra/clangd/index/FileIndex.cpp

index 92a11cd..91914be 100644 (file)
@@ -190,7 +190,13 @@ FileShardedIndex::FileShardedIndex(IndexFileIn Input, PathRef HintPath)
   }
 }
 std::vector<PathRef> FileShardedIndex::getAllFiles() const {
-  return std::vector<PathRef>(Shards.keys().begin(), Shards.keys().end());
+  // It should be enough to construct a vector with {Shards.keys().begin(),
+  // Shards.keys().end()} but MSVC fails to compile that.
+  std::vector<PathRef> Result;
+  Result.reserve(Shards.size());
+  for (PathRef Key : Shards.keys())
+    Result.push_back(Key);
+  return Result;
 }
 
 IndexFileIn FileShardedIndex::getShard(PathRef File) const {