diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e77fcd8..7768bd82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,7 +189,6 @@ target_sources(ccls PRIVATE src/include_complete.cc src/method.cc src/lex_utils.cc - src/lsp_diagnostic.cc src/lsp.cc src/match.cc src/message_handler.cc diff --git a/src/import_pipeline.cc b/src/import_pipeline.cc index bff9f65b..8f53c8c0 100644 --- a/src/import_pipeline.cc +++ b/src/import_pipeline.cc @@ -491,30 +491,6 @@ bool IndexMain_DoCreateIndexUpdate(TimestampManager* timestamp_manager) { response->current->file->last_modification_time); } - #if false - #define PRINT_SECTION(name) \ - if (response->perf.name) { \ - total += response->perf.name; \ - output << " " << #name << ": " << FormatMicroseconds(response->perf.name); \ - } - std::stringstream output; - long long total = 0; - output << "[perf]"; - PRINT_SECTION(index_parse); - PRINT_SECTION(index_build); - PRINT_SECTION(index_save_to_disk); - PRINT_SECTION(index_load_cached); - PRINT_SECTION(querydb_id_map); - PRINT_SECTION(index_make_delta); - output << "\n total: " << FormatMicroseconds(total); - output << " path: " << response->current_index->path; - LOG_S(INFO) << output.rdbuf(); - #undef PRINT_SECTION - - if (response->is_interactive) - LOG_S(INFO) << "Applying IndexUpdate" << std::endl << update.ToString(); - #endif - Index_OnIndexed reply(std::move(update), response->perf); queue->on_indexed.PushBack(std::move(reply), response->is_interactive); } @@ -551,13 +527,7 @@ bool IndexMergeIndexUpdates() { if (!to_join) break; did_merge = true; - // Timer time; root->update.Merge(std::move(to_join->update)); - // time.ResetAndPrint("Joined querydb updates for files: " + - // StringJoinMap(root->update.files_def_update, - //[](const QueryFile::DefUpdate& update) { - // return update.path; - //})); } queue->on_indexed.PushFront(std::move(*root)); diff --git a/src/lsp_diagnostic.cc b/src/lsp_diagnostic.cc deleted file mode 100644 index e6a000d7..00000000 --- a/src/lsp_diagnostic.cc +++ /dev/null @@ -1,5 +0,0 @@ -#include "lsp_diagnostic.h" - -#include "match.h" -#include "queue_manager.h" -#include "working_files.h" diff --git a/src/messages/text_document_completion.cc b/src/messages/text_document_completion.cc index 14e82af4..3c9831b0 100644 --- a/src/messages/text_document_completion.cc +++ b/src/messages/text_document_completion.cc @@ -165,7 +165,7 @@ void FilterAndSortCompletionResponse( if (!enable) return; - ScopedPerfTimer timer("FilterAndSortCompletionResponse"); + ScopedPerfTimer timer{"FilterAndSortCompletionResponse"}; // Used to inject more completions. #if false diff --git a/src/test.cc b/src/test.cc index 69b9c13e..266ab030 100644 --- a/src/test.cc +++ b/src/test.cc @@ -23,11 +23,6 @@ #include #endif -void Write(const std::vector& strs) { - for (const std::string& str : strs) - std::cout << str << std::endl; -} - std::string ToString(const rapidjson::Document& document) { rapidjson::StringBuffer buffer; rapidjson::PrettyWriter writer(buffer); @@ -46,41 +41,6 @@ void ParseTestExpectation( TextReplacer* replacer, std::vector* flags, std::unordered_map* output_sections) { -#if false -#include "bar.h" - - void foo(); - - /* - // DOCS for TEXT_REPLACE: - // Each line under TEXT_REPLACE is a replacement, ie, the two entries will be - // considered equivalent. This is useful for USRs which vary across files. - - // DOCS for EXTRA_FLAGS: - // Additional flags to pass to clang. - - // DOCS for OUTPUT: - // If no name is given assume to be this file name. If there is not an output - // section for a file it is not checked. - - TEXT_REPLACE: - foo <===> bar - one <===> two - - EXTRA_FLAGS: - -std=c++14 - - OUTPUT: - {} - - OUTPUT: bar.cc - {} - - OUTPUT: bar.h - {} - */ -#endif - // Scan for EXTRA_FLAGS: { bool in_output = false; @@ -201,34 +161,6 @@ void DiffDocuments(std::string path, << "):" << std::endl; std::cout << joined_actual_output << std::endl; std::cout << std::endl; - - int max_diff = 5; - - size_t len = std::min(actual_output.size(), expected_output.size()); - 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; - break; - } - - std::cout << "Line " << i << " differs:" << std::endl; - std::cout << " expected: " << expected_output[i] << std::endl; - std::cout << " actual: " << actual_output[i] << std::endl; - } - } - - if (actual_output.size() > len) { - std::cout << "Additional output in actual:" << std::endl; - for (size_t i = len; i < actual_output.size(); ++i) - std::cout << " " << actual_output[i] << std::endl; - } - - if (expected_output.size() > len) { - std::cout << "Additional output in expected:" << std::endl; - for (size_t i = len; i < expected_output.size(); ++i) - std::cout << " " << expected_output[i] << std::endl; - } } void VerifySerializeToFrom(IndexFile* file) { @@ -322,9 +254,6 @@ bool RunIndexTests(const std::string& filter_path, bool enable_update) { bool had_extra_flags = !flags.empty(); if (!AnyStartsWith(flags, "-x")) flags.push_back("-xc++"); - // Use c++14 by default, because MSVC STL is written assuming that. - if (!AnyStartsWith(flags, "-std")) - flags.push_back("-std=c++14"); flags.push_back("-resource-dir=" + GetDefaultResourceDirectory()); if (had_extra_flags) { std::cout << "For " << path << std::endl; diff --git a/src/timer.cc b/src/timer.cc index 94bc9cf5..96ec658c 100644 --- a/src/timer.cc +++ b/src/timer.cc @@ -8,13 +8,9 @@ Timer::Timer() { long long Timer::ElapsedMicroseconds() const { std::chrono::time_point end = Clock::now(); - long long elapsed = elapsed_; - if (start_.has_value()) { - elapsed += - std::chrono::duration_cast(end - *start_) - .count(); - } - return elapsed; + return elapsed_ + + std::chrono::duration_cast(end - start_) + .count(); } long long Timer::ElapsedMicrosecondsAndReset() { @@ -38,25 +34,18 @@ void Timer::ResetAndPrint(const std::string& message) { } void Timer::Pause() { - assert(start_.has_value()); - std::chrono::time_point end = Clock::now(); long long elapsed = - std::chrono::duration_cast(end - *start_) + std::chrono::duration_cast(end - start_) .count(); elapsed_ += elapsed; - start_ = std::nullopt; } void Timer::Resume() { - assert(!start_.has_value()); start_ = Clock::now(); } -ScopedPerfTimer::ScopedPerfTimer(const std::string& message) - : message_(message) {} - ScopedPerfTimer::~ScopedPerfTimer() { timer_.ResetAndPrint(message_); } diff --git a/src/timer.h b/src/timer.h index 182da671..061801db 100644 --- a/src/timer.h +++ b/src/timer.h @@ -1,7 +1,5 @@ #pragma once -#include - #include #include @@ -25,15 +23,14 @@ struct Timer { void Resume(); // Raw start time. - std::optional> start_; + std::chrono::time_point start_; // Elapsed time. - long long elapsed_ = 0; + long long elapsed_; }; struct ScopedPerfTimer { - ScopedPerfTimer(const std::string& message); ~ScopedPerfTimer(); - Timer timer_; std::string message_; + Timer timer_; };