Skip to content

Commit 01be6b6

Browse files
committed
Code cleanup
1 parent 0578185 commit 01be6b6

File tree

8 files changed

+18
-22
lines changed

8 files changed

+18
-22
lines changed

src/Memory.hpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,20 @@ namespace kanzi {
119119
#define IS_BIG_ENDIAN 1
120120
#elif defined(_AIX) || defined(__hpux) || (defined(__sun) && defined(__sparc)) || defined(__OS400__) || defined(__MVS__)
121121
#define IS_BIG_ENDIAN 1
122-
#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN|| defined(__LITTLE_ENDIAN__)
122+
#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__)
123123
#define IS_BIG_ENDIAN 0
124-
#elif defined(_WIN32)
125-
#define IS_BIG_ENDIAN 0
126-
#elif defined(__amd64) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
124+
#else
127125
#define IS_BIG_ENDIAN 0
128126
#endif
129127
#endif
130128

131129

132-
static inline bool isBigEndian() {
130+
static inline bool isLittleEndian() {
133131
#if defined(IS_BIG_ENDIAN)
134-
return IS_BIG_ENDIAN == 1;
132+
return IS_BIG_ENDIAN == 0;
135133
#else
136-
union { uint32 v; uint8 c[4]; } one = { 0x03020100 };
137-
return one.c[0] == 0;
138-
//const union { uint32 u; uint8 c[4]; } one = { 1 };
139-
//return one.c[3] == 1;
134+
uint32_t v = 1;
135+
return *(char*) &v;
140136
#endif
141137
}
142138

src/io/CompressedInputStream.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const int CompressedInputStream::MAX_BLOCK_ID = int((uint(1) << 31) - 1);
4343

4444
CompressedInputStream::CompressedInputStream(InputStream& is,
4545
int tasks,
46-
string entropy,
47-
string transform,
46+
const string& entropy,
47+
const string& transform,
4848
int blockSize,
4949
int checksum,
5050
uint64 originalSize,

src/io/CompressedInputStream.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ namespace kanzi
134134
// with values read from the bitstream header.
135135
CompressedInputStream(InputStream& is,
136136
int jobs = 1,
137-
std::string entropy = "NONE",
138-
std::string transform = "NONE",
137+
const std::string& entropy = "NONE",
138+
const std::string& transform = "NONE",
139139
int blockSize = 4*1024*1024,
140140
int checksum = 0,
141141
uint64 originalSize = 0,

src/io/CompressedOutputStream.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const int CompressedOutputStream::MAX_CONCURRENCY = 64;
4545

4646
CompressedOutputStream::CompressedOutputStream(OutputStream& os,
4747
int tasks,
48-
string entropy,
49-
string transform,
48+
const string& entropy,
49+
const string& transform,
5050
int blockSize,
5151
int checksum,
5252
uint64 fileSize,

src/io/CompressedOutputStream.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ namespace kanzi {
104104
public:
105105
CompressedOutputStream(OutputStream& os,
106106
int jobs = 1,
107-
std::string entropy = "NONE",
108-
std::string transform = "NONE",
107+
const std::string& entropy = "NONE",
108+
const std::string& transform = "NONE",
109109
int blockSize = 4*1024*1024,
110110
int checksum = 0,
111111
uint64 originalSize = 0,

src/test/TestCompressedStream.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ void testSeek(string name)
281281
cout << pos1 << " / " << pos2 << endl;
282282
cis.read(buf, 100);
283283

284-
for (int i = 0; i < 100; i++)
285-
cout << buf[i];
284+
for (int j = 0; j < 100; j++)
285+
cout << buf[j];
286286

287287
cout << endl << endl;
288288
}

src/test/TestTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ int testTransformsSpeed(const string& name)
359359
srand((uint)time(nullptr));
360360
int iter = 50000;
361361

362-
if ((name == "ROLZ") || (name == "SRT") || (name == "RANK"))
362+
if ((name == "ROLZ") || (name == "SRT") || (name == "RANK") || (name == "MTFT"))
363363
iter = 4000;
364364

365365
int size = 30000;

src/transform/BWT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ bool BWT::inverseMergeTPSI(SliceArray<byte>& input, SliceArray<byte>& output, in
238238

239239
#define S(t, d) ptr = _buffer[t]; \
240240
d[n] = byte(ptr); \
241-
t = ptr >> 8;
241+
t = ptr >> 8
242242

243243
while (n < 0) {
244244
S(t0, d0);

0 commit comments

Comments
 (0)