From 440c6c5325d750e85f76f79aedfd499d3a639976 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Sat, 20 May 2017 01:23:01 -0700 Subject: [PATCH] Small code cleanup --- src/command_line.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/command_line.cc b/src/command_line.cc index 98683857..3d52b2a2 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -83,6 +83,11 @@ struct CodeCompleteCache { optional cached_completion_position; NonElidedVector cached_results; NonElidedVector cached_diagnostics; + + bool IsCacheValid(lsTextDocumentPositionParams position) const { + return cached_path == position.textDocument.uri.GetPath() && + cached_completion_position == position.position; + } }; @@ -1735,8 +1740,7 @@ bool QueryDbMainLoop( delete message; }, message.release(), std::placeholders::_1, std::placeholders::_2); - if (code_complete_cache->cached_path == params.textDocument.uri.GetPath() && - code_complete_cache->cached_completion_position == params.position) { + if (code_complete_cache->IsCacheValid(params)) { std::cerr << "[complete] Using cached completion results at " << params.position.ToString() << std::endl; callback(code_complete_cache->cached_results, code_complete_cache->cached_diagnostics); } @@ -1810,8 +1814,7 @@ bool QueryDbMainLoop( delete message; }, message.release(), search, active_param, std::placeholders::_1); - if (signature_cache->cached_path == params.textDocument.uri.GetPath() && - signature_cache->cached_completion_position == params.position) { + if (signature_cache->IsCacheValid(params)) { std::cerr << "[complete] Using cached completion results at " << params.position.ToString() << std::endl; callback(signature_cache->cached_results, signature_cache->cached_diagnostics); }