Skip to content

Commit 25f8dde

Browse files
Merge pull request #553 from x-mass/develop
refactor: include inflate stream only when needed
2 parents 091ac6e + b9e749b commit 25f8dde

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

include/ccapi_cpp/service/ccapi_service.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
#define CCAPI_WEBSOCKET_WRITE_BUFFER_SIZE (1 << 20)
2828
#endif
2929

30+
#define CCAPI_REQUIRES_INFLATE_STREAM \
31+
((defined(CCAPI_ENABLE_SERVICE_MARKET_DATA) && \
32+
(defined(CCAPI_ENABLE_EXCHANGE_HUOBI) || defined(CCAPI_ENABLE_EXCHANGE_HUOBI_USDT_SWAP) || defined(CCAPI_ENABLE_EXCHANGE_HUOBI_COIN_SWAP))) || \
33+
(defined(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) && \
34+
(defined(CCAPI_ENABLE_EXCHANGE_HUOBI_USDT_SWAP) || defined(CCAPI_ENABLE_EXCHANGE_HUOBI_COIN_SWAP) || defined(CCAPI_ENABLE_EXCHANGE_BITMART))))
35+
3036
#include <regex>
3137

3238
#include "boost/asio/strand.hpp"
@@ -50,7 +56,9 @@
5056
#include "ccapi_cpp/ccapi_fix_connection.h"
5157
#include "ccapi_cpp/ccapi_http_connection.h"
5258
#include "ccapi_cpp/ccapi_http_retry.h"
59+
#if CCAPI_REQUIRES_INFLATE_STREAM
5360
#include "ccapi_cpp/ccapi_inflate_stream.h"
61+
#endif
5462
#include "ccapi_cpp/ccapi_queue.h"
5563
#include "ccapi_cpp/ccapi_request.h"
5664
#include "ccapi_cpp/ccapi_session_configs.h"
@@ -1437,10 +1445,7 @@ class Service : public std::enable_shared_from_this<Service> {
14371445
} else if (stream.got_binary()) {
14381446
CCAPI_LOGGER_DEBUG("received a binary message: " + UtilAlgorithm::stringToHex(std::string(data, dataSize)));
14391447

1440-
#if defined(CCAPI_ENABLE_SERVICE_MARKET_DATA) && \
1441-
(defined(CCAPI_ENABLE_EXCHANGE_HUOBI) || defined(CCAPI_ENABLE_EXCHANGE_HUOBI_USDT_SWAP) || defined(CCAPI_ENABLE_EXCHANGE_HUOBI_COIN_SWAP)) || \
1442-
defined(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) && \
1443-
(defined(CCAPI_ENABLE_EXCHANGE_HUOBI_USDT_SWAP) || defined(CCAPI_ENABLE_EXCHANGE_HUOBI_COIN_SWAP) || defined(CCAPI_ENABLE_EXCHANGE_BITMART))
1448+
#if CCAPI_REQUIRES_INFLATE_STREAM
14441449

14451450
if (this->needDecompressWebsocketMessage) {
14461451
std::string decompressed;
@@ -1660,13 +1665,8 @@ class Service : public std::enable_shared_from_this<Service> {
16601665
// std::regex convertNumberToStringInJsonRegex{"(\\[|,|\":)\\s?(-?\\d+\\.?\\d*)"};
16611666
// std::string convertNumberToStringInJsonRewrite{"$1\"$2\""};
16621667
bool needDecompressWebsocketMessage{};
1663-
#if defined(CCAPI_ENABLE_SERVICE_MARKET_DATA) && \
1664-
(defined(CCAPI_ENABLE_EXCHANGE_HUOBI) || defined(CCAPI_ENABLE_EXCHANGE_HUOBI_USDT_SWAP) || defined(CCAPI_ENABLE_EXCHANGE_HUOBI_COIN_SWAP)) || \
1665-
defined(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT) && \
1666-
(defined(CCAPI_ENABLE_EXCHANGE_HUOBI_USDT_SWAP) || defined(CCAPI_ENABLE_EXCHANGE_HUOBI_COIN_SWAP) || defined(CCAPI_ENABLE_EXCHANGE_BITMART))
1667-
1668+
#if CCAPI_REQUIRES_INFLATE_STREAM
16681669
InflateStream inflater;
1669-
16701670
#endif
16711671

16721672
std::array<char, CCAPI_JSON_PARSE_BUFFER_SIZE> jsonParseBuffer;

0 commit comments

Comments
 (0)