summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2024-10-01 14:14:10 -0400
committerJosh Ferrell <josh@vector35.com>2024-10-01 14:14:10 -0400
commitfc28e5142593e69a960ab8dd72ff88a2f06065da (patch)
tree7353a6e13aadd1f5ac79e0569a3325c242079eb3
parent998f3f7dfa79a742575ee118ffc629e542dd9790 (diff)
Improve c++ http api performance
-rw-r--r--http.cpp22
-rw-r--r--http.h26
2 files changed, 24 insertions, 24 deletions
diff --git a/http.cpp b/http.cpp
index 084f4a85..12490a41 100644
--- a/http.cpp
+++ b/http.cpp
@@ -229,7 +229,7 @@ namespace BinaryNinja::Http
}
- Request::Request(string method, string url, unordered_map<string, string> headers,
+ Request::Request(string method, string url, const unordered_map<string, string>& headers,
vector<pair<string, string>> params, std::function<bool(size_t, size_t)> downloadProgress,
std::function<bool(size_t, size_t)> uploadProgress) :
m_method(method),
@@ -252,7 +252,7 @@ namespace BinaryNinja::Http
}
- Request::Request(string method, string url, unordered_map<string, string> headers,
+ Request::Request(string method, string url, const unordered_map<string, string>& headers,
vector<pair<string, string>> params, vector<uint8_t> body, std::function<bool(size_t, size_t)> downloadProgress,
std::function<bool(size_t, size_t)> uploadProgress) :
m_method(method),
@@ -276,7 +276,7 @@ namespace BinaryNinja::Http
}
- Request::Request(string method, string url, unordered_map<string, string> headers,
+ Request::Request(string method, string url, const unordered_map<string, string>& headers,
vector<pair<string, string>> params, vector<pair<string, string>> formFields,
std::function<bool(size_t, size_t)> downloadProgress, std::function<bool(size_t, size_t)> uploadProgress) :
m_method(method),
@@ -303,7 +303,7 @@ namespace BinaryNinja::Http
}
- Request::Request(string method, string url, unordered_map<string, string> headers,
+ Request::Request(string method, string url, const unordered_map<string, string>& headers,
vector<pair<string, string>> params, vector<MultipartField> formFields,
std::function<bool(size_t, size_t)> downloadProgress, std::function<bool(size_t, size_t)> uploadProgress) :
m_method(method),
@@ -331,31 +331,31 @@ namespace BinaryNinja::Http
}
- Request Request::Get(string url, unordered_map<string, string> headers, vector<pair<string, string>> params,
+ Request Request::Get(string url, const unordered_map<string, string>& headers, const vector<pair<string, string>>& params,
std::function<bool(size_t, size_t)> downloadProgress, std::function<bool(size_t, size_t)> uploadProgress)
{
return Request("GET", url, headers, params, downloadProgress, uploadProgress);
}
- Request Request::Post(string url, unordered_map<string, string> headers, vector<pair<string, string>> params,
- vector<uint8_t> body, std::function<bool(size_t, size_t)> downloadProgress,
+ Request Request::Post(string url, const unordered_map<string, string>& headers, const vector<pair<string, string>>& params,
+ const vector<uint8_t>& body, std::function<bool(size_t, size_t)> downloadProgress,
std::function<bool(size_t, size_t)> uploadProgress)
{
return Request("POST", url, headers, params, body, downloadProgress, uploadProgress);
}
- Request Request::Post(string url, unordered_map<string, string> headers, vector<pair<string, string>> params,
- vector<pair<string, string>> formFields, std::function<bool(size_t, size_t)> downloadProgress,
+ Request Request::Post(string url, const unordered_map<string, string>& headers, const vector<pair<string, string>>& params,
+ const vector<pair<string, string>>& formFields, std::function<bool(size_t, size_t)> downloadProgress,
std::function<bool(size_t, size_t)> uploadProgress)
{
return Request("POST", url, headers, params, formFields, downloadProgress, uploadProgress);
}
- Request Request::Post(string url, unordered_map<string, string> headers, vector<pair<string, string>> params,
- vector<MultipartField> formFields, std::function<bool(size_t, size_t)> downloadProgress,
+ Request Request::Post(string url, const unordered_map<string, string>& headers, const vector<pair<string, string>>& params,
+ const vector<MultipartField>& formFields, std::function<bool(size_t, size_t)> downloadProgress,
std::function<bool(size_t, size_t)> uploadProgress)
{
return Request("POST", url, headers, params, formFields, downloadProgress, uploadProgress);
diff --git a/http.h b/http.h
index 6edb801a..83b898a9 100644
--- a/http.h
+++ b/http.h
@@ -207,7 +207,7 @@ namespace BinaryNinja::Http
\param downloadProgress Function to call for download progress updates
\param uploadProgress Function to call for upload progress updates
*/
- Request(_STD_STRING method, _STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers = {},
+ Request(_STD_STRING method, _STD_STRING url, const _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING>& headers = {},
_STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params = {},
std::function<bool(size_t, size_t)> downloadProgress = {},
std::function<bool(size_t, size_t)> uploadProgress = {});
@@ -223,7 +223,7 @@ namespace BinaryNinja::Http
\param downloadProgress Function to call for download progress updates
\param uploadProgress Function to call for upload progress updates
*/
- Request(_STD_STRING method, _STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
+ Request(_STD_STRING method, _STD_STRING url, const _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING>& headers,
_STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params, _STD_VECTOR<uint8_t> body,
std::function<bool(size_t, size_t)> downloadProgress = {},
std::function<bool(size_t, size_t)> uploadProgress = {});
@@ -239,7 +239,7 @@ namespace BinaryNinja::Http
\param downloadProgress Function to call for download progress updates
\param uploadProgress Function to call for upload progress updates
*/
- Request(_STD_STRING method, _STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
+ Request(_STD_STRING method, _STD_STRING url, const _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING>& headers,
_STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params,
_STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> formFields,
std::function<bool(size_t, size_t)> downloadProgress = {},
@@ -256,7 +256,7 @@ namespace BinaryNinja::Http
\param downloadProgress Function to call for download progress updates
\param uploadProgress Function to call for upload progress updates
*/
- Request(_STD_STRING method, _STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
+ Request(_STD_STRING method, _STD_STRING url, const _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING>& headers,
_STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params, _STD_VECTOR<MultipartField> formFields,
std::function<bool(size_t, size_t)> downloadProgress = {},
std::function<bool(size_t, size_t)> uploadProgress = {});
@@ -271,8 +271,8 @@ namespace BinaryNinja::Http
\param uploadProgress Function to call for upload progress updates
\return Request structure with specified fields
*/
- static Request Get(_STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers = {},
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params = {},
+ static Request Get(_STD_STRING url, const _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING>& headers = {},
+ const _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>>& params = {},
std::function<bool(size_t, size_t)> downloadProgress = {},
std::function<bool(size_t, size_t)> uploadProgress = {});
@@ -287,8 +287,8 @@ namespace BinaryNinja::Http
\param uploadProgress Function to call for upload progress updates
\return Request structure with specified fields
*/
- static Request Post(_STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers = {},
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params = {}, _STD_VECTOR<uint8_t> body = {},
+ static Request Post(_STD_STRING url, const _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING>& headers = {},
+ const _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>>& params = {}, const _STD_VECTOR<uint8_t>& body = {},
std::function<bool(size_t, size_t)> downloadProgress = {},
std::function<bool(size_t, size_t)> uploadProgress = {});
@@ -303,9 +303,9 @@ namespace BinaryNinja::Http
\param uploadProgress Function to call for upload progress updates
\return Request structure with specified fields
*/
- static Request Post(_STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> formFields,
+ static Request Post(_STD_STRING url, const _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING>& headers,
+ const _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>>& params,
+ const _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>>& formFields,
std::function<bool(size_t, size_t)> downloadProgress = {},
std::function<bool(size_t, size_t)> uploadProgress = {});
@@ -320,8 +320,8 @@ namespace BinaryNinja::Http
\param uploadProgress Function to call for upload progress updates
\return Request structure with specified fields
*/
- static Request Post(_STD_STRING url, _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING> headers,
- _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>> params, _STD_VECTOR<MultipartField> formFields,
+ static Request Post(_STD_STRING url, const _STD_UNORDERED_MAP<_STD_STRING, _STD_STRING>& headers,
+ const _STD_VECTOR<std::pair<_STD_STRING, _STD_STRING>>& params, const _STD_VECTOR<MultipartField>& formFields,
std::function<bool(size_t, size_t)> downloadProgress = {},
std::function<bool(size_t, size_t)> uploadProgress = {});
};