[PATCH] D37101: [clangd] Add support for snippet completions

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 6 08:03:02 PDT 2017


ilya-biryukov added inline comments.


================
Comment at: clangd/ClangdUnit.cpp:376
+
+    CompletionItem Item{InsertTextFormat::PlainText};
+
----------------
rwols wrote:
> ilya-biryukov wrote:
> > Implementations of this function in `PlainTextCompletionItemsCollector` and `SnippetCompletionItemsCollector` are the same.
> > Maybe make `ProcessChunks` virtual instead?
> > 
> > Or maybe consider replacing inheritance with a `bool` flag. Inheritance does not seem to buy us much here. This looks simpler:
> > ```
> > if (EnableSnippets)
> >   ProcessChunksWithSnippets(CCS, Item);
> > else
> >   ProcessChunksWithoutSnippets(CCS, Item);
> > 
> > ```
> > 
> > 
> I went with the "make ProcessChunks virtual" approach, wouldn't your suggestion have an impact on performance? There'd be a check for every completion item now.
Oh, that should not make any difference performance-wise. There is many more branching on each completion item even if we assume all the function calls are inlined.
And virtual calls are not free either.


https://reviews.llvm.org/D37101





More information about the cfe-commits mailing list