mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 03:55:49 +00:00
Fix integer sign comparison
This commit is contained in:
parent
015195036c
commit
be4d37dac3
@ -20,7 +20,7 @@ std::string ElideLongPath(Config* config, const std::string& path) {
|
||||
if (config->includeCompletionMaximumPathLength <= 0)
|
||||
return path;
|
||||
|
||||
if (path.size() <= config->includeCompletionMaximumPathLength)
|
||||
if ((int)path.size() <= config->includeCompletionMaximumPathLength)
|
||||
return path;
|
||||
|
||||
size_t start = path.size() - config->includeCompletionMaximumPathLength;
|
||||
|
@ -57,7 +57,7 @@ optional<std::string> ReadJsonRpcContentFrom(
|
||||
// Read content.
|
||||
std::string content;
|
||||
content.reserve(content_length);
|
||||
for (size_t i = 0; i < content_length; ++i) {
|
||||
for (int i = 0; i < content_length; ++i) {
|
||||
optional<char> c = read();
|
||||
if (!c) {
|
||||
LOG_S(INFO) << "No more input when reading content body";
|
||||
|
@ -27,7 +27,7 @@ lsPosition CharPos(std::string_view search,
|
||||
char character,
|
||||
int character_offset) {
|
||||
lsPosition result;
|
||||
int index = 0;
|
||||
size_t index = 0;
|
||||
while (index < search.size()) {
|
||||
char c = search[index];
|
||||
if (c == character)
|
||||
@ -91,13 +91,13 @@ void DecorateIncludePaths(const std::smatch& match,
|
||||
optional<lsRange> ExtractQuotedRange(int line_number, const std::string& line) {
|
||||
// Find starting and ending quote.
|
||||
int start = 0;
|
||||
while (start < line.size()) {
|
||||
while (start < (int)line.size()) {
|
||||
char c = line[start];
|
||||
++start;
|
||||
if (c == '"' || c == '<')
|
||||
break;
|
||||
}
|
||||
if (start == line.size())
|
||||
if (start == (int)line.size())
|
||||
return nullopt;
|
||||
|
||||
int end = (int)line.size();
|
||||
|
@ -95,7 +95,7 @@ std::shared_ptr<TValue> LruCache<TKey, TValue>::TryTake(const TKey& key) {
|
||||
template <typename TKey, typename TValue>
|
||||
void LruCache<TKey, TValue>::Insert(const TKey& key,
|
||||
const std::shared_ptr<TValue>& value) {
|
||||
if (entries_.size() >= max_entries_)
|
||||
if ((int)entries_.size() >= max_entries_)
|
||||
entries_.erase(std::min_element(entries_.begin(), entries_.end()));
|
||||
|
||||
Entry entry;
|
||||
|
@ -456,7 +456,7 @@ struct TextDocumentCodeActionHandler
|
||||
std::unordered_set<std::string> include_absolute_paths;
|
||||
|
||||
// Find include candidate strings.
|
||||
for (int i = 0; i < db->symbols.size(); ++i) {
|
||||
for (size_t i = 0; i < db->symbols.size(); ++i) {
|
||||
if (include_absolute_paths.size() > kMaxResults)
|
||||
break;
|
||||
if (db->GetSymbolDetailedName(i).find(include_query) ==
|
||||
|
@ -221,7 +221,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
||||
bool did_fail_check = false;
|
||||
|
||||
std::string character = *request->params.context->triggerCharacter;
|
||||
char preceding_index = request->params.position.character - 2;
|
||||
int preceding_index = request->params.position.character - 2;
|
||||
|
||||
// If the character is '"', '<' or '/', make sure that the line starts with '#'.
|
||||
if (character == "\"" || character == "<" || character == "/") {
|
||||
@ -238,7 +238,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
||||
}
|
||||
// If the character is > but - does not preced it, or if it is : and :
|
||||
// does not preced it, do not show completion results.
|
||||
else if (preceding_index < buffer_line.size()) {
|
||||
else if (preceding_index < (int)buffer_line.size()) {
|
||||
char preceding = buffer_line[preceding_index];
|
||||
did_fail_check = (preceding != '-' && character == ">") ||
|
||||
(preceding != ':' && character == ":");
|
||||
|
@ -106,7 +106,7 @@ struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
|
||||
if (!isspace(c))
|
||||
query_without_space += c;
|
||||
|
||||
for (int i = 0; i < db->symbols.size(); ++i) {
|
||||
for (int i = 0; i < (int)db->symbols.size(); ++i) {
|
||||
std::string_view detailed_name = db->GetSymbolDetailedName(i);
|
||||
if (SubsequenceMatch(query_without_space, detailed_name)) {
|
||||
// Do not show the same entry twice.
|
||||
|
@ -428,28 +428,28 @@ int ComputeGuessScore(const std::string& a, const std::string& b) {
|
||||
const int kMatchPostfixWeight = 1;
|
||||
|
||||
int score = 0;
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
|
||||
// Increase score based on matching prefix.
|
||||
for (i = 0; i < a.length() && i < b.length(); ++i) {
|
||||
for (i = 0; i < a.size() && i < b.size(); ++i) {
|
||||
if (a[i] != b[i])
|
||||
break;
|
||||
score += kMatchPrefixWeight;
|
||||
}
|
||||
|
||||
// Reduce score based on mismatched directory distance.
|
||||
for (int j = i; j < a.length(); ++j) {
|
||||
for (size_t j = i; j < a.size(); ++j) {
|
||||
if (a[j] == '/')
|
||||
score -= kMismatchDirectoryWeight;
|
||||
}
|
||||
for (int j = i; j < b.length(); ++j) {
|
||||
for (size_t j = i; j < b.size(); ++j) {
|
||||
if (b[j] == '/')
|
||||
score -= kMismatchDirectoryWeight;
|
||||
}
|
||||
|
||||
// Increase score based on common ending. Don't increase as much as matching
|
||||
// prefix or directory distance.
|
||||
for (int offset = 1; offset <= a.length() && offset <= b.length(); ++offset) {
|
||||
for (size_t offset = 1; offset <= a.size() && offset <= b.size(); ++offset) {
|
||||
if (a[a.size() - offset] != b[b.size() - offset])
|
||||
break;
|
||||
score += kMatchPostfixWeight;
|
||||
|
@ -81,7 +81,7 @@ void DiffDocuments(std::string path,
|
||||
int max_diff = 5;
|
||||
|
||||
size_t len = std::min(actual_output.size(), expected_output.size());
|
||||
for (int i = 0; i < len; ++i) {
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
if (actual_output[i] != expected_output[i]) {
|
||||
if (--max_diff < 0) {
|
||||
std::cout << "(... more lines may differ ...)" << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user