Skip to content

Commit

Permalink
Changed relevant magic numbers to units of measure
Browse files Browse the repository at this point in the history
  • Loading branch information
pitzelrivera committed Sep 28, 2022
1 parent 7fe0fac commit 02967a9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ std::shared_ptr<HBITMAP> saveImage(const string &data)
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);

DWORD size = 2 * 1024;
const int bytesPerKibibyte = 1024;
DWORD size = 2 * bytesPerKibibyte;
std::vector<BYTE> buf(size, 0);
DWORD skipped;
if (!CryptStringToBinaryA(data.data(), 0, CRYPT_STRING_BASE64, buf.data(), &size, &skipped, nullptr)) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/checksums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace {

QByteArray calcAdler32(QIODevice *device)
{
const bytesPerKibibyte = 1024;
const int bytesPerKibibyte = 1024;
const qint64 BUFSIZE(500 * bytesPerKibibyte); // 500 KiB
if (device->size() == 0) {
return QByteArray();
Expand Down
3 changes: 2 additions & 1 deletion src/gui/folderwatcher_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ void WatcherThread::run()
// If this buffer fills up before we've extracted its data we will lose
// change information. Therefore start big.
size_t bufferSize = 4096 * 10;
const size_t maxBuffer = 64 * 1024;
const int bytesPerKibiByte = 1024;
const size_t maxBuffer = 64 * bytesPerKibiByte;

while (true) {
switch (watchChanges(bufferSize)) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/socketapi/socketapi_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class BloomFilter
// Initialize with m=1024 bits and k=2 (high and low 16 bits of a qHash).
// For a client navigating in less than 100 directories, this gives us a probability less than
// (1-e^(-2*100/1024))^2 = 0.03147872136 false positives.
const static int NumBits = 1024;
const static int NumBytesPerKibibyte = 1024;

public:
BloomFilter()
Expand Down
3 changes: 2 additions & 1 deletion src/gui/updater/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ QString Updater::getSystemInfo()
process.waitForFinished();
QByteArray output = process.readAllStandardOutput();
qCDebug(lcUpdater) << "Sys Info size: " << output.length();
if (output.length() > 1024)
const int bytesPerKibiByte = 1024;
if (output.length() > bytesPerKibiByte)
output.clear(); // don't send too much.

return QString::fromLocal8Bit(output.toBase64());
Expand Down
3 changes: 2 additions & 1 deletion test/testutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ private slots:
//NOTE: in order for the plural to work we would need to load the english translation

quint64 sec = 1000;
quint64 hour = 3600 * sec;
const int secondsPerHour = 3600;
quint64 hour = secondsPerHour * sec;

QDateTime current = QDateTime::currentDateTimeUtc();

Expand Down

0 comments on commit 02967a9

Please sign in to comment.