mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Reuse loaded file contents in indexer; clear large state before caching.
This commit is contained in:
parent
85f3c00376
commit
1f3f69b221
@ -834,6 +834,8 @@ struct CacheManager {
|
||||
}
|
||||
|
||||
std::shared_ptr<Entry> UpdateAndReturnOldFile(std::shared_ptr<Entry> entry) {
|
||||
entry->file->ClearLargeState();
|
||||
|
||||
const auto it = files_.find(entry->file->path);
|
||||
if (it != files_.end()) {
|
||||
std::shared_ptr<Entry> old = std::move(it->second);
|
||||
@ -895,7 +897,6 @@ bool IndexMain_DoIndex(Config* config,
|
||||
}
|
||||
|
||||
assert(current_index);
|
||||
// assert(previous_index);
|
||||
|
||||
// TODO: get real value for is_interactive
|
||||
Index_DoIdMap response(std::move(current_index), request->perf,
|
||||
@ -1162,6 +1163,10 @@ std::vector<IndexProcess_Response> DoParseFile(
|
||||
//
|
||||
// We do this to minimize the race between indexing a file and capturing the
|
||||
// file contents.
|
||||
//
|
||||
// TODO: We might be able to optimize perf by only copying for files in
|
||||
// working_files. We can pass that same set of files to the indexer as
|
||||
// well. We then default to a fast file-copy if not in working set.
|
||||
std::vector<FileContents> file_contents;
|
||||
for (const auto& it : cache_loader->caches) {
|
||||
const std::unique_ptr<IndexFile>& index = it.second;
|
||||
|
@ -356,6 +356,10 @@ std::string IndexFile::ToString() {
|
||||
return Serialize(*this);
|
||||
}
|
||||
|
||||
void IndexFile::ClearLargeState() {
|
||||
file_contents_ = "";
|
||||
}
|
||||
|
||||
IndexType::IndexType(IndexTypeId id, const std::string& usr)
|
||||
: def(usr), id(id) {
|
||||
assert(usr.size() > 0);
|
||||
@ -1603,6 +1607,9 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
|
||||
|
||||
FileConsumer file_consumer(file_consumer_shared, file);
|
||||
IndexParam param(&tu, &file_consumer);
|
||||
for (const FileContents& contents : file_contents) {
|
||||
param.file_contents[contents.path] = contents.content;
|
||||
}
|
||||
|
||||
CXFile cx_file = clang_getFile(tu.cx_tu, file.c_str());
|
||||
param.primary_file = ConsumeFile(¶m, cx_file);
|
||||
|
@ -498,6 +498,7 @@ struct IndexFile {
|
||||
IndexVar* Resolve(IndexVarId id);
|
||||
|
||||
std::string ToString();
|
||||
void ClearLargeState();
|
||||
};
|
||||
|
||||
struct FileContents {
|
||||
|
Loading…
Reference in New Issue
Block a user