This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Get rid of regexes in CanonicalIncludes
ClosedPublic

Authored by ilya-biryukov on Aug 22 2018, 1:13 AM.

Diff Detail

Event Timeline

ilya-biryukov created this revision.Aug 22 2018, 1:13 AM
ioeric added inline comments.Aug 22 2018, 4:17 AM
clangd/index/CanonicalIncludes.h
43–46

It seems that this is only file path suffix matching (by components) now. We should probably rename the function to be explicit.

64

It might be worth documenting why this is useful (i.e. the optimization).

ilya-biryukov marked 2 inline comments as done.Aug 22 2018, 5:52 AM
ilya-biryukov added inline comments.
clangd/index/CanonicalIncludes.h
43–46

Renamed to addPathSuffixMapping, updated the doc.

ilya-biryukov marked 2 inline comments as done.
  • s/addSuffixMapping/addFileSuffixMapping
  • Document the intention of MaxSuffixComponents
ioeric accepted this revision.Aug 22 2018, 6:17 AM
ioeric added inline comments.
clangd/index/CanonicalIncludes.cpp
25

Would int Components = begin(Suffix) - end(Suffix); work here?

76

Maybe merge Components and break condition into for loop condition?

This revision is now accepted and ready to land.Aug 22 2018, 6:17 AM
ilya-biryukov marked 2 inline comments as done.
  • Use std::distance instead of an explicit loop
  • Merge break into loop condition
clangd/index/CanonicalIncludes.cpp
25

Surprisingly, operator - gives byte difference.
But std::distance gives the expected result, added that.

Thanks!

This revision was automatically updated to reflect the committed changes.