arphaman added inline comments.

================
Comment at: clangd/ClangdServer.cpp:296
+
+  const int sourceSize = sizeof(DEFAULT_SOURCE_EXTENSIONS) / 
sizeof(DEFAULT_SOURCE_EXTENSIONS[0]);
+  const int headerSize = sizeof(DEFAULT_HEADER_EXTENSIONS) / 
sizeof(DEFAULT_HEADER_EXTENSIONS[0]);
----------------
You can use LLVM's function `array_lengthof` here and on the next line instead.


================
Comment at: clangd/ClangdServer.cpp:302
+  std::string *p;
+  p = std::find(DEFAULT_SOURCE_EXTENSIONS,
+                DEFAULT_SOURCE_EXTENSIONS + sourceSize,
----------------
It might be better to use a `StringSet` instead of an array of strings and use 
one lowercase/uppercase lookup:

```
llvm::StringSet<> DEFAULT_SOURCE_EXTENSIONS[] = {".cpp", ".c", ".cc", ".cxx", 
".c++", ".m", ".mm"};
// Handles both lower and uppercase extensions and source/header files in one 
if/else construct:
if (DEFAULT_SOURCE_EXTENSIONS.count(llvm::sys::path::extension(path).lower())) {
  ...
  isSourceFile = true;
} else if 
(DEFAULT_HEADER_EXTENSIONS.count(llvm::sys::path::extension(path).lower())) {
  ...
  isSourceFile = false;
}
```


https://reviews.llvm.org/D36150



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to