Skip to content

Commit 5ae85af

Browse files
committed
Got rid of INT_MAX and some other refactoring.
1 parent 627f2e6 commit 5ae85af

4 files changed

Lines changed: 24 additions & 14 deletions

File tree

include/react/common/Containers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ class NodeVector
7575
///////////////////////////////////////////////////////////////////////////////////////////////////
7676
struct SplitTag {};
7777

78-
template <typename T, int N>
78+
template <typename T, uint N>
7979
class NodeBuffer
8080
{
8181
public:
8282
using DataT = std::array<T*,N>;
8383
using iterator = typename DataT::iterator;
8484
using const_iterator = typename DataT::const_iterator;
8585

86-
static const int split_size = N / 2;
86+
static const uint split_size = N / 2;
8787

8888
NodeBuffer() :
8989
size_{ 0 },
@@ -167,7 +167,7 @@ class NodeBuffer
167167
}
168168

169169
DataT nodes_;
170-
int size_;
170+
uint size_;
171171
iterator front_;
172172
iterator back_;
173173
};

include/react/common/SourceIdSet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class SourceIdSet
113113
}
114114

115115
private:
116-
MutexT mutex_;
117-
DataT data_;
116+
MutexT mutex_;
117+
DataT data_;
118118
bool isSorted_ = false;
119119

120120
void sort()

include/react/common/TopoQueue.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <algorithm>
1212
#include <array>
13+
#include <limits>
1314
#include <vector>
1415

1516
#include "tbb/enumerable_thread_specific.h"
@@ -48,7 +49,7 @@ class TopoQueue
4849
{
4950
next_.clear();
5051

51-
minLevel_ = INT_MAX;
52+
minLevel_ = std::numeric_limits<int>::max();
5253
for (const auto& e : data_)
5354
{
5455
auto l = LevelFunctorT{}(e);
@@ -76,7 +77,7 @@ class TopoQueue
7677

7778
DataT next_;
7879
DataT data_;
79-
int minLevel_ = INT_MAX;
80+
int minLevel_ = std::numeric_limits<int>::max();
8081
};
8182

8283
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -107,14 +108,13 @@ class WeightedRange
107108
using WeightFunctorT = NodeWeightHelper<ValueT>;
108109

109110
WeightedRange() = default;
110-
WeightedRange(const WeightedRange& other) = default;
111+
WeightedRange(const WeightedRange&) = default;
111112

112113
WeightedRange(const TIt& a, const TIt& b, uint weight) :
113114
begin_{ a },
114115
end_{ b },
115116
weight_{ weight }
116-
{
117-
}
117+
{}
118118

119119
WeightedRange(WeightedRange& source, tbb::split)
120120
{
@@ -188,7 +188,7 @@ class ConcurrentTopoQueue
188188
uint totalWeight = 0;
189189

190190
// Determine current min level
191-
minLevel_ = INT_MAX;
191+
minLevel_ = std::numeric_limits<int>::max();
192192
for (const auto& buf : collectBuffer_)
193193
if (minLevel_ > buf.MinLevel)
194194
minLevel_ = buf.MinLevel;
@@ -208,7 +208,7 @@ class ConcurrentTopoQueue
208208
v.resize(std::distance(v.begin(), p));
209209

210210
// Calc new min level and weight for this buffer
211-
buf.MinLevel = INT_MAX;
211+
buf.MinLevel = std::numeric_limits<int>::max();
212212
int oldWeight = buf.Weight;
213213
buf.Weight = 0;
214214
for (const T& x : v)
@@ -245,11 +245,11 @@ class ConcurrentTopoQueue
245245
struct ThreadLocalBuffer
246246
{
247247
DataT Data;
248-
int MinLevel = INT_MAX;
248+
int MinLevel = std::numeric_limits<int>::max();
249249
uint Weight = 0;
250250
};
251251

252-
int minLevel_ = INT_MAX;
252+
int minLevel_ = std::numeric_limits<int>::max();
253253
DataT nodes_;
254254
RangeT range_;
255255

include/react/detail/Defs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66

77
#pragma once
88

9+
#define WINDOWS_LEAN_AND_MEAN
10+
#define NOMINMAX
11+
12+
#ifdef max
13+
#undef max
14+
#endif
15+
#ifdef min
16+
#undef min
17+
#endif
18+
919
#include <cassert>
1020

1121
///////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)