mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-30 19:37:08 +00:00
Fix ComputeGuessScore and delete dead code
Thanks to CXuesong
This commit is contained in:
parent
72ee893d26
commit
a37782dc0c
@ -268,7 +268,7 @@ std::vector<Project::Entry> LoadFromDirectoryListing(ProjectConfig *config) {
|
|||||||
e.filename = file;
|
e.filename = file;
|
||||||
e.args = GetCompilerArgumentForFile(file);
|
e.args = GetCompilerArgumentForFile(file);
|
||||||
if (e.args.empty())
|
if (e.args.empty())
|
||||||
e.args.push_back("%clang"); // Add a Dummy.
|
e.args.push_back("%clang");
|
||||||
e.args.push_back(Intern(e.filename));
|
e.args.push_back(Intern(e.filename));
|
||||||
proc.Process(e);
|
proc.Process(e);
|
||||||
result.push_back(e);
|
result.push_back(e);
|
||||||
@ -376,7 +376,7 @@ LoadEntriesFromDirectory(ProjectConfig *project,
|
|||||||
// argument guessing.
|
// argument guessing.
|
||||||
int ComputeGuessScore(std::string_view a, std::string_view b) {
|
int ComputeGuessScore(std::string_view a, std::string_view b) {
|
||||||
// Increase score based on common prefix and suffix. Prefixes are prioritized.
|
// Increase score based on common prefix and suffix. Prefixes are prioritized.
|
||||||
if (a.size() < b.size())
|
if (a.size() > b.size())
|
||||||
std::swap(a, b);
|
std::swap(a, b);
|
||||||
size_t i = std::mismatch(a.begin(), a.end(), b.begin()).first - a.begin();
|
size_t i = std::mismatch(a.begin(), a.end(), b.begin()).first - a.begin();
|
||||||
size_t j = std::mismatch(a.rbegin(), a.rend(), b.rbegin()).first - a.rbegin();
|
size_t j = std::mismatch(a.rbegin(), a.rend(), b.rbegin()).first - a.rbegin();
|
||||||
@ -419,19 +419,6 @@ void Project::Load(const std::string &root) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::SetArgsForFile(const std::vector<const char *> &args,
|
|
||||||
const std::string &path) {
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
for (auto &[root, folder] : root2folder) {
|
|
||||||
auto it = folder.path2entry_index.find(path);
|
|
||||||
if (it != folder.path2entry_index.end()) {
|
|
||||||
// The entry already exists in the project, just set the flags.
|
|
||||||
folder.entries[it->second].args = args;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Project::Entry Project::FindEntry(const std::string &path,
|
Project::Entry Project::FindEntry(const std::string &path,
|
||||||
bool can_be_inferred) {
|
bool can_be_inferred) {
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
|
Loading…
Reference in New Issue
Block a user