[PATCH] D135226: [clangd] Optimize Dex::generateProximityURIs().

Adam Czachorowski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 5 09:34:57 PDT 2022


adamcz added inline comments.


================
Comment at: clang-tools-extra/clangd/index/dex/Dex.cpp:358
+// Returns        ^
+const char *findPathInURI(const char *S) {
+  // Skip over scheme.
----------------
Is there a reason why you're doing this with manual manipulation of C-strings instead of StringRefs? I suspect passing StringRef here was not the problem, turning it into an std::string, from another std::string inside ParsedURI was.

Something like:
S = S.drop_while([](char c) { return c == ':'; });
S.consume_front(":");
if (S.consume_front("//")) {
  S = S.drop_while([](char c) { return c == '/'; });
  S.consume_front("/");
}

return S;

would be a bit more readable and less likely to have an off-by-one somewhere, imho.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135226/new/

https://reviews.llvm.org/D135226



More information about the cfe-commits mailing list