Skip to content

Commit 68dc5c4

Browse files
authored
Merge pull request #2419 from jwillemsen/jwi-memcpyconstexrp
Use constexpr for constant instead of enum
2 parents 552fbb8 + 88cac2f commit 68dc5c4

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

ACE/tests/Memcpy_Test.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void
6262
testit (int type)
6363
{
6464
char buffer[16];
65-
size_t const size = 16;
65+
size_t constexpr size = 16;
6666

6767
switch (type)
6868
{
@@ -72,38 +72,37 @@ testit (int type)
7272

7373
}
7474

75-
namespace { enum { ITERATIONS = 100000000 }; }
75+
constexpr size_t ITERATIONS = 100000000;
7676

7777
int
7878
run_main (int, ACE_TCHAR *[])
7979
{
8080
ACE_START_TEST (ACE_TEXT ("Memcpy_Test"));
8181

82-
//ACE_Time_Value start, now;
8382
struct timeval start, now;
8483

85-
for (int i = ITERATIONS; i > 0; --i)
84+
for (size_t i = ITERATIONS; i > 0; --i)
8685
testit (0);
8786

8887
start = ACE_High_Res_Timer::gettimeofday_hr ();
89-
for (int j = ITERATIONS; j > 0; --j)
88+
for (size_t j = ITERATIONS; j > 0; --j)
9089
testit (0);
9190

9291
now = ACE_High_Res_Timer::gettimeofday_hr ();
9392

94-
double fast = 1000000 *(now.tv_sec - start.tv_sec) +
93+
double const fast = 1000000 *(now.tv_sec - start.tv_sec) +
9594
now.tv_usec - start.tv_usec;
9695
ACE_DEBUG ((LM_DEBUG,
9796
ACE_TEXT ("%f uSec per iteration for fast version.\n"),
9897
fast / ITERATIONS));
9998

10099
start = ACE_High_Res_Timer::gettimeofday_hr ();
101-
for (int k = ITERATIONS; k > 0; --k)
100+
for (size_t k = ITERATIONS; k > 0; --k)
102101
testit (1);
103102

104103
now = ACE_High_Res_Timer::gettimeofday_hr ();
105104

106-
double slow = 1000000 * (now.tv_sec-start.tv_sec) + now.tv_usec - start.tv_usec;
105+
double const slow = 1000000 * (now.tv_sec-start.tv_sec) + now.tv_usec - start.tv_usec;
107106
ACE_DEBUG ((LM_DEBUG,
108107
ACE_TEXT ("%f uSec per iteration for slow version.\n"),
109108
slow / ITERATIONS));

0 commit comments

Comments
 (0)