Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed Nov 5, 2024
1 parent 0578185 commit 01be6b6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 22 deletions.
16 changes: 6 additions & 10 deletions src/Memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,20 @@ namespace kanzi {
#define IS_BIG_ENDIAN 1
#elif defined(_AIX) || defined(__hpux) || (defined(__sun) && defined(__sparc)) || defined(__OS400__) || defined(__MVS__)
#define IS_BIG_ENDIAN 1
#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN|| defined(__LITTLE_ENDIAN__)
#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__)
#define IS_BIG_ENDIAN 0
#elif defined(_WIN32)
#define IS_BIG_ENDIAN 0
#elif defined(__amd64) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
#else
#define IS_BIG_ENDIAN 0
#endif
#endif


static inline bool isBigEndian() {
static inline bool isLittleEndian() {
#if defined(IS_BIG_ENDIAN)
return IS_BIG_ENDIAN == 1;
return IS_BIG_ENDIAN == 0;
#else
union { uint32 v; uint8 c[4]; } one = { 0x03020100 };
return one.c[0] == 0;
//const union { uint32 u; uint8 c[4]; } one = { 1 };
//return one.c[3] == 1;
uint32_t v = 1;
return *(char*) &v;
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions src/io/CompressedInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const int CompressedInputStream::MAX_BLOCK_ID = int((uint(1) << 31) - 1);

CompressedInputStream::CompressedInputStream(InputStream& is,
int tasks,
string entropy,
string transform,
const string& entropy,
const string& transform,
int blockSize,
int checksum,
uint64 originalSize,
Expand Down
4 changes: 2 additions & 2 deletions src/io/CompressedInputStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ namespace kanzi
// with values read from the bitstream header.
CompressedInputStream(InputStream& is,
int jobs = 1,
std::string entropy = "NONE",
std::string transform = "NONE",
const std::string& entropy = "NONE",
const std::string& transform = "NONE",
int blockSize = 4*1024*1024,
int checksum = 0,
uint64 originalSize = 0,
Expand Down
4 changes: 2 additions & 2 deletions src/io/CompressedOutputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const int CompressedOutputStream::MAX_CONCURRENCY = 64;

CompressedOutputStream::CompressedOutputStream(OutputStream& os,
int tasks,
string entropy,
string transform,
const string& entropy,
const string& transform,
int blockSize,
int checksum,
uint64 fileSize,
Expand Down
4 changes: 2 additions & 2 deletions src/io/CompressedOutputStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ namespace kanzi {
public:
CompressedOutputStream(OutputStream& os,
int jobs = 1,
std::string entropy = "NONE",
std::string transform = "NONE",
const std::string& entropy = "NONE",
const std::string& transform = "NONE",
int blockSize = 4*1024*1024,
int checksum = 0,
uint64 originalSize = 0,
Expand Down
4 changes: 2 additions & 2 deletions src/test/TestCompressedStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ void testSeek(string name)
cout << pos1 << " / " << pos2 << endl;
cis.read(buf, 100);

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

cout << endl << endl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/TestTransforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ int testTransformsSpeed(const string& name)
srand((uint)time(nullptr));
int iter = 50000;

if ((name == "ROLZ") || (name == "SRT") || (name == "RANK"))
if ((name == "ROLZ") || (name == "SRT") || (name == "RANK") || (name == "MTFT"))
iter = 4000;

int size = 30000;
Expand Down
2 changes: 1 addition & 1 deletion src/transform/BWT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ bool BWT::inverseMergeTPSI(SliceArray<byte>& input, SliceArray<byte>& output, in

#define S(t, d) ptr = _buffer[t]; \
d[n] = byte(ptr); \
t = ptr >> 8;
t = ptr >> 8

while (n < 0) {
S(t0, d0);
Expand Down

0 comments on commit 01be6b6

Please sign in to comment.