[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.
Johan Vikström via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 31 08:24:27 PDT 2019
jvikstrom marked an inline comment as done.
jvikstrom added inline comments.
================
Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1125
+ Old = std::move(FileToHighlightings[File]);
+ FileToHighlightings[File] = Highlightings;
+ }
----------------
hokein wrote:
> ilya-biryukov wrote:
> > NIT: avoid copying (from `Highlightings` into the map) under a lock, make the copy outside the lock instead
> I think we can even avoid copy, since we only use the `Highlightings` for calculating the diff.
>
> Maybe just
>
> ```
> {
> std::lock_guard<std::mutex> Lock(HighlightingsMutex);
> Old = std::move(FileToHighlightings[File]);
> }
> // calculate the diff.
> {
> std::lock_guard<std::mutex> Lock(HighlightingsMutex);
> FileToHighlightings[File] = std::move(Highlightings);
> }
> ```
I think I changed this to only lock once (and copy instead) at the same time me and @ilya-biryukov were talking about the race condition (?)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64475/new/
https://reviews.llvm.org/D64475
More information about the cfe-commits
mailing list