use constant expressions for compiler optimization (thx Ryelow)
This commit is contained in:
parent
d371022291
commit
47904d2e6f
|
|
@ -8,7 +8,7 @@ bool isRunning = false;
|
|||
std::string username;
|
||||
int placeId;
|
||||
|
||||
void Discord::Initialize(std::string joinScriptUrl)
|
||||
void Discord::Initialize(const std::string joinScriptUrl)
|
||||
{
|
||||
// Check if Discord should be enabled by checking if the binary is the client as well as if the binary's containing folder contains a ".nodiscord" file
|
||||
std::string path = Helpers::getModulePath();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ bool Helpers::isASCII(const std::string& s)
|
|||
{
|
||||
return !std::any_of(s.begin(), s.end(), [](char c) {
|
||||
return static_cast<unsigned char>(c) > 127;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/313970/how-to-convert-an-instance-of-stdstring-to-lower-case
|
||||
|
|
@ -71,7 +71,7 @@ std::vector<BYTE> Helpers::base64Decode(const std::string_view data)
|
|||
}
|
||||
|
||||
// https://stackoverflow.com/a/28269049
|
||||
std::map<std::string, std::string> Helpers::parseQueryString(std::string query)
|
||||
std::map<std::string, std::string> Helpers::parseQueryString(const std::string query)
|
||||
{
|
||||
std::istringstream stream(query);
|
||||
std::map<std::string, std::string> parsed;
|
||||
|
|
@ -90,7 +90,7 @@ std::map<std::string, std::string> Helpers::parseQueryString(std::string query)
|
|||
return parsed;
|
||||
}
|
||||
|
||||
std::string Helpers::joinQueryString(std::map<std::string, std::string> query)
|
||||
std::string Helpers::joinQueryString(const std::map<std::string, std::string> query)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << "?";
|
||||
|
|
@ -107,7 +107,7 @@ std::string Helpers::joinQueryString(std::map<std::string, std::string> query)
|
|||
}
|
||||
|
||||
// https://stackoverflow.com/a/12097772
|
||||
std::string Helpers::ws2s(std::wstring widestring)
|
||||
std::string Helpers::ws2s(const std::wstring widestring)
|
||||
{
|
||||
std::string string;
|
||||
std::transform(widestring.begin(), widestring.end(), std::back_inserter(string), [](wchar_t c) {
|
||||
|
|
@ -144,7 +144,7 @@ std::string Helpers::getISOTimestamp()
|
|||
return std::string(buffer);
|
||||
}
|
||||
|
||||
std::pair<bool, std::map<std::string, std::string>> Helpers::parseURL(std::string url)
|
||||
std::pair<bool, std::map<std::string, std::string>> Helpers::parseURL(const std::string url)
|
||||
{
|
||||
CURLU* curl = curl_url();
|
||||
CURLUcode result = curl_url_set(curl, CURLUPART_URL, url.c_str(), 0);
|
||||
|
|
@ -179,7 +179,7 @@ std::pair<bool, std::map<std::string, std::string>> Helpers::parseURL(std::strin
|
|||
return std::make_pair(success, map);
|
||||
}
|
||||
|
||||
std::pair<bool, std::string> Helpers::httpGet(std::string url)
|
||||
std::pair<bool, std::string> Helpers::httpGet(const std::string url)
|
||||
{
|
||||
bool success = false;
|
||||
std::string data;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
//#define SERVER
|
||||
// This is commented out since our CI defines this automatically
|
||||
// #define SERVER
|
||||
|
||||
#define BASE_URL "https://tadah.rocks"
|
||||
#define DISCORD_APP_ID 923705431543668736
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <discord_rpc.h>
|
||||
#include <discord_register.h>
|
||||
#include <rapidjson/document.h>
|
||||
|
|
@ -12,7 +11,7 @@
|
|||
|
||||
class Discord {
|
||||
public:
|
||||
static void Initialize(std::string joinScriptUrl);
|
||||
static void Initialize(const std::string joinScriptUrl);
|
||||
static void Cleanup();
|
||||
private:
|
||||
static void Update();
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ public:
|
|||
static bool isASCII(const std::string& s);
|
||||
static std::string toLower(std::string s);
|
||||
static std::vector<BYTE> base64Decode(const std::string_view data);
|
||||
static std::map<std::string, std::string> parseQueryString(std::string query);
|
||||
static std::string joinQueryString(std::map<std::string, std::string> query);
|
||||
static std::string ws2s(std::wstring widestring);
|
||||
static std::map<std::string, std::string> parseQueryString(const std::string query);
|
||||
static std::string joinQueryString(const std::map<std::string, std::string> query);
|
||||
static std::string ws2s(const std::wstring widestring);
|
||||
static size_t write(char* contents, size_t size, size_t memory, void* pointer);
|
||||
static std::string getModulePath();
|
||||
static std::string getISOTimestamp();
|
||||
static std::pair<bool, std::map<std::string, std::string>> parseURL(std::string url);
|
||||
static std::pair<bool, std::string> httpGet(std::string url);
|
||||
static std::pair<bool, std::map<std::string, std::string>> parseURL(const std::string url);
|
||||
static std::pair<bool, std::string> httpGet(const std::string url);
|
||||
};
|
||||
Loading…
Reference in New Issue