Skip to content

Commit 763df97

Browse files
committed
simplify code
1 parent c26dcb1 commit 763df97

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

source/gameanalytics/Http/GAHttpCurl.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ namespace gameanalytics
1313

1414
const size_t new_len = s->packet.size() + size * nmemb + 1;
1515
s->packet.reserve(new_len);
16-
1716
s->packet.insert(s->packet.end(), reinterpret_cast<char*>(ptr), reinterpret_cast<char*>(ptr) + size * nmemb);
18-
s->packet.push_back('\0');
1917

2018
return size*nmemb;
2119
}
@@ -32,34 +30,32 @@ namespace gameanalytics
3230

3331
GAHttpWrapper::Response GAHttpCurl::sendRequest(std::string const& url, std::string const& auth, std::vector<uint8_t> const& payloadData, bool useGzip, void* userData)
3432
{
35-
CURL* curl = nullptr;
36-
CURLcode res{};
37-
curl = curl_easy_init();
33+
CURL* curl = curl_easy_init();
3834
if (!curl)
3935
{
4036
return {};
4137
}
4238

4339
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
4440

45-
GAHttpWrapper::Response s = {};
41+
GAHttpWrapper::Response response = {};
4642

4743
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
48-
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
44+
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
4945

5046
createRequest(curl, url, auth, payloadData, useGzip);
5147

52-
res = curl_easy_perform(curl);
48+
CURLcode res = curl_easy_perform(curl);
5349
if (res != CURLE_OK)
5450
{
5551
logging::GALogger::d("%s", curl_easy_strerror(res));
5652
return {};
5753
}
5854

59-
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &s.code);
55+
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response.code);
6056
curl_easy_cleanup(curl);
6157

62-
return s;
58+
return response;
6359
}
6460

6561
void GAHttpCurl::createRequest(CURL *curl, std::string const& url, std::string const& auth, const std::vector<uint8_t>& payloadData, bool gzip)

0 commit comments

Comments
 (0)