From d8ace7fb4a53bd2b1aed5f8671383bdd0db59cfe Mon Sep 17 00:00:00 2001 From: Xinyu Hou Date: Tue, 13 Sep 2016 11:09:47 -0400 Subject: [PATCH] #4740 Used global const rather than macro --- src/lib/synergy/StreamChunker.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/synergy/StreamChunker.cpp b/src/lib/synergy/StreamChunker.cpp index 839c4341..eba98572 100644 --- a/src/lib/synergy/StreamChunker.cpp +++ b/src/lib/synergy/StreamChunker.cpp @@ -35,8 +35,9 @@ using namespace std; -#define FAKE_HEARTBEAT_THRESHOLD 3 -#define CHUNK_SIZE 512 * 1024; // 512kb + +static const double g_fakeHeartbeatThreshold = 3; +static const size_t g_chunkSize = 512 * 1024; //512kb bool StreamChunker::s_isChunkingFile = false; bool StreamChunker::s_interruptFile = false; @@ -68,7 +69,7 @@ StreamChunker::sendFile( // send chunk messages with a fixed chunk size size_t sentLength = 0; - size_t chunkSize = CHUNK_SIZE; + size_t chunkSize = g_chunkSize; Stopwatch fakeHeartbeatStopwatch; fakeHeartbeatStopwatch.start(); file.seekg (0, std::ios::beg); @@ -80,7 +81,7 @@ StreamChunker::sendFile( break; } - if (fakeHeartbeatStopwatch.getTime() > FAKE_HEARTBEAT_THRESHOLD) { + if (fakeHeartbeatStopwatch.getTime() > g_fakeHeartbeatThreshold) { events->addEvent(Event(events->forFile().keepAlive(), eventTarget)); fakeHeartbeatStopwatch.reset(); } @@ -133,12 +134,12 @@ StreamChunker::sendClipboard( // send clipboard chunk with a fixed size size_t sentLength = 0; - size_t chunkSize = CHUNK_SIZE; + size_t chunkSize = g_chunkSize; Stopwatch fakeHeartbeatStopwatch; fakeHeartbeatStopwatch.start(); while (true) { - if (fakeHeartbeatStopwatch.getTime() > FAKE_HEARTBEAT_THRESHOLD) { + if (fakeHeartbeatStopwatch.getTime() > g_fakeHeartbeatThreshold) { events->addEvent(Event(events->forFile().keepAlive(), eventTarget)); fakeHeartbeatStopwatch.reset(); }