Skip to content

Commit

Permalink
perf: improve performance and fix potential problems
Browse files Browse the repository at this point in the history
  • Loading branch information
wyq777x authored and Serein207 committed Aug 29, 2024
1 parent 806b1a1 commit 75856c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Infrastructure/Network/NetworkClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Infrastructure/Utils/Debug.h>
#include <boost/url/param.hpp>
#include <boost/url/params_view.hpp>
#include <initializer_list>
#include <memory>
#include <nlohmann/json.hpp>
#include <string>
Expand Down
6 changes: 3 additions & 3 deletions src/Infrastructure/Network/NetworkClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ class NetworkClient {
NetworkClient(net::ssl::context& ctx);
static NetworkClient* getInstance();
//cache data processing
std::string generateCacheKey(
static std::string generateCacheKey(
http::verb verb,
const urls::url_view& url,
const std::initializer_list<urls::param>& params); //auxiliary function to generate cache key

bool isCacheEntryExpired(const CacheEntry& entry) const {
static bool isCacheEntryExpired(const CacheEntry& entry) const {

Check failure on line 108 in src/Infrastructure/Network/NetworkClient.h

View workflow job for this annotation

GitHub Actions / Analyze (c-cpp)

static member function ‘static bool evento::NetworkClient::isCacheEntryExpired(const evento::CacheEntry&)’ cannot have cv-qualifier
auto now = std::chrono::steady_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::hours>(now - entry.insertTime);
return duration.count() >= 3;
Expand All @@ -117,7 +117,7 @@ class NetworkClient {
cacheList.erase(it->second);
currentCacheSize -= it->second->second.size;
}
cacheList.push_front({key, std::move(entry)});
cacheList.emplace_front({key, std::move(entry)});

Check failure on line 120 in src/Infrastructure/Network/NetworkClient.h

View workflow job for this annotation

GitHub Actions / Analyze (c-cpp)

no matching function for call to ‘std::__cxx11::list<std::pair<std::__cxx11::basic_string<char>, evento::CacheEntry> >::emplace_front(<brace-enclosed initializer list>)’
cacheMap[key] = cacheList.begin();
currentCacheSize += cacheList.begin()->second.size;

Expand Down

0 comments on commit 75856c0

Please sign in to comment.