Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Ezra committed Sep 21, 2019
1 parent 54d33bc commit 7d599a7
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 42 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -14,7 +14,7 @@ Usage

<pre>

% slimfastq *file.fastq* *new-file.sfq* : compress *file.fastq* to *new-file.sfq*
% slimfastq *file.fastq* *new-file.sfq* : compress *file.fastq* to *new-file.sfq*
% slimfastq -1 *file.fastq* *new-file.sfq*: compress *file.fastq* to *new-file.sfq*, using little cpu/memory resources
(-1 to -4 are levels of compression/resources tradeoffs, -3 is default)

Expand All @@ -39,7 +39,7 @@ The BSD 3-Clause

Platform
--------
slimfastq was developed and optimized for x86_64 GNU/Linux. For other system's support requests, please contact Josef Ezra.
slimfastq was developed and optimized for x86_64 GNU/Linux. For other system's support requests, please contact Josef Ezra.

Contact
-------
Expand Down
8 changes: 4 additions & 4 deletions coder.hpp
Expand Up @@ -30,11 +30,11 @@ class RCoder {
FilerSave* m_out;

public:
void init(FilerSave* f_out) {
void init(FilerSave* f_out) {
m_out = f_out;
m_in = NULL;
low=0;
range=(UINT32)-1;
low=0;
range=(UINT32)-1;
}

void init(FilerLoad* f_in) {
Expand Down Expand Up @@ -89,7 +89,7 @@ class RCoder {
low += temp;
code -= temp;
range*= freq;

while( range<TOP ) {
rarely_if ( (low^(low+range)) & (0xffULL<<56) )
range = ((UINT32(low)|(TOP-1))-UINT32(low));
Expand Down
2 changes: 1 addition & 1 deletion config.cpp
Expand Up @@ -348,7 +348,7 @@ void Config::init(int argc, char **argv, int ver) {

UINT64 comp_size = get_long("comp.size", 0);
if (comp_size > 0 and
comp_size != file_size)
comp_size != file_size)
croak("expected compressed file size to be %lld", comp_size);
}
}
Expand Down
4 changes: 2 additions & 2 deletions filer.cpp
Expand Up @@ -79,7 +79,7 @@ struct OneFile {
// Note: -D_FILE_OFFSET_BITS=64 is required
UINT64 offs = offset;
offs *= FILER_PAGE;
fseek(m_in, offs , SEEK_SET);
fseek(m_in, offs , SEEK_SET);
UINT32 cnt = fread(page, 1, FILER_PAGE, m_in);
if (cnt != FILER_PAGE)
croak("Failed reading page index %d: %s", offset);
Expand Down Expand Up @@ -283,7 +283,7 @@ void FilerLoad::load_page() {
assert(m_node_i == 0);
onef.read_page(onef.files[m_onef_i].first, m_buff);
m_node_p = onef.files[m_onef_i].node;
if (m_node_p)
if (m_node_p)
onef.read_page(m_node_p, (UCHAR*) m_node);
m_node_i = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion filer.tst.cpp
Expand Up @@ -36,7 +36,7 @@ void test_big_file() {
assert(not unlink_failed);
printf("Delete %s\n", tst_filename);
}

}

int main(int, char**) {
Expand Down
4 changes: 2 additions & 2 deletions log64_ranger.hpp
Expand Up @@ -121,9 +121,9 @@ class Log64Ranger {
i < NSYM;
i ++ ) {

rarely_if(iend == i)
rarely_if(iend == i)
syms[ iend++ ] = i;

if (sumf + freq[i] + 1 <= prob)
sumf += freq[i] + 1;
else
Expand Down
1 change: 1 addition & 0 deletions main.cpp
Expand Up @@ -33,6 +33,7 @@
// QltSave - saves the quality measure (optimized for 64 values)
// During load (decode)
// UsrLoad - reads record fragments from RecLoad, GenLoad, QltLoad and prints in order

// under the hood, use WORM file system to implement multiple range coders streams. Note that the
// file's first block is metadata + info.

Expand Down
6 changes: 2 additions & 4 deletions power_ranger.hpp
Expand Up @@ -33,8 +33,6 @@

#include <string.h>

class BFileSave ;
class BFileLoad ;
class PowerRanger {
enum {
STEP=14,
Expand All @@ -51,7 +49,7 @@ class PowerRanger {

void normalize() {
for (UINT32 i = total = 0; i < iend; i++)
total += (freq[i] >>= 1 );
total += (freq[i] >>= 1 );
}

inline UCHAR down_level(int i) {
Expand Down Expand Up @@ -118,7 +116,7 @@ class PowerRanger {
i < NSYM;
i ++ ) {

rarely_if(iend == i)
rarely_if(iend == i)
syms[ iend++ ] = i;

if (sumf + freq[i] + 1 <= prob)
Expand Down
8 changes: 4 additions & 4 deletions qlts.cpp
Expand Up @@ -81,7 +81,7 @@ void QltSave::save_1(const UCHAR* buf, size_t size) {
exranger.put(&rcoder, b);
m_last.extra_hi_qlt ++ ;
}
last = calc_last_1(last, b);
last = calc_last_1(last, b);
}
}

Expand All @@ -98,7 +98,7 @@ void QltSave::save_2(const UCHAR* buf, size_t size) {
exranger.put(&rcoder, b);
m_last.extra_hi_qlt ++ ;
}
last = calc_last_2(last, b);
last = calc_last_2(last, b);
}
}

Expand Down Expand Up @@ -194,11 +194,11 @@ UINT32 QltLoad::load_2(UCHAR* buf, const size_t size) {

UINT32 QltLoad::load_3(UCHAR* buf, const size_t size) {

UINT32 last = 0 ;
UINT32 last = 0 ;
UINT32 delta = 5;
UCHAR q1 = 0, q2 = 0;
UINT32 di = 0;

for (UCHAR* p = buf; p < buf + size ; p++) {
PREFETCH(ranger + last);
UCHAR b = ranger[last].get(&rcoder);
Expand Down
8 changes: 4 additions & 4 deletions usrs.cpp
Expand Up @@ -96,7 +96,7 @@ void UsrSave::load_page() {
m_cur = start;
m_end = PLL_STRT + cnt ;

if (m_cur == m_end)
if (m_cur == m_end)
m_valid = false;
else
m_page_count++;
Expand Down Expand Up @@ -252,7 +252,7 @@ bool UsrSave::get_oversized_record(int cur, bool from_get) {

#define CHK_VALID if (!m_valid) croak("record %llu: seems truncated", g_record_count)
#define PUT_LINE(X) do { c = load_char(); X->put_chr(c); } while (c != '\n' and m_valid)

PUT_LINE(x_lrec);
CHK_VALID;

Expand Down Expand Up @@ -333,7 +333,7 @@ bool UsrSave::get_record() {

m_cur++;
}

mp.qlt = &(m_buff[m_cur]);
m_cur += m_llen;
CHECK_OVERFLOW;
Expand Down Expand Up @@ -527,7 +527,7 @@ int UsrLoad::decode() {
update();
if (g_record_count > n_recs)
break;

UCHAR* b_rec = (flip ? m_rep : m_rec)+1 ;
UCHAR* p_rec = (flip ? m_rec : m_rep)+1 ;

Expand Down
2 changes: 1 addition & 1 deletion usrs.hpp
Expand Up @@ -86,7 +86,7 @@ class UsrSave : public UsrBase {
UINT64 estimate_rec_limit();

bool m_valid;
UCHAR m_buff[PLL_LAST+10];
UCHAR m_buff[PLL_LAST+10];
size_t m_page_count;
int m_cur, m_end;
FILE *m_in;
Expand Down
32 changes: 16 additions & 16 deletions utest.cpp
Expand Up @@ -49,7 +49,7 @@

void test_filer() {
TITLE("filer");
const char* fname = "/tmp/utest~filer";
const char* fname = "/tmp/utest~filer";
{
FILE *fh = fopen(fname, "w");
assert(fh);
Expand Down Expand Up @@ -139,7 +139,7 @@ void rc_init(bool load=0) {
assert(fh);
FilerLoad::init(fh);
rc->init(filer_l = new FilerLoad("utest", &_valid));
}
}
else {
FILE* fh = fopen(fname, "w");
assert(fh);
Expand Down Expand Up @@ -284,7 +284,7 @@ void test_power_ranger_extra() {
{
// FILE *fh = fopen(fname, "w");
// assert(fh);
//
//
// FilerSave filer(fh) ;
// assert(filer.is_valid());

Expand All @@ -300,7 +300,7 @@ void test_power_ranger_extra() {
ranger.put_u(r, (i&0x7f));
for (UINT64 i=0; i < 1000; i++)
ranger.put_u(r, i);
for (UINT64 i=0xfff0; i < 0x10234; i++)
for (UINT64 i=0xfff0; i < 0x10234; i++)
ranger.put_u(r, i);
for (int i = 0; i < 12; i++)
ranger.put_u(r, array[i]);
Expand All @@ -314,7 +314,7 @@ void test_power_ranger_extra() {
// FILE *fh = fopen(fname, "r");
// assert(fh);
// bool valid;
//
//
// FilerLoad filer(fh, &valid) ;
// assert(filer.is_valid());

Expand Down Expand Up @@ -348,60 +348,60 @@ void test_power_ranger_extra() {
}
for (int i = 0; i < 8; i++) {
long u = ranger.get_u(r);
assert(u == arrai[i]);
assert(u == arrai[i]);
}
rc_finit();
}
}

// void test_recbase() {
//
//
// TITLE("test RecBase");
// // const UCHAR* mystr = (const UCHAR*)"welcome to Amsterdam had have a )*(&^(*4758*^&%)) +++~ time!";
// // int mystr_len = strlen((const char*)mystr);
// {
// FILE *fh = fopen(fname, "w");
// assert(fh);
//
//
// FilerSave filer(fh) ;
// assert(filer.is_valid());
//
//
// RecBase base ;
// BZERO(base);
// base.range_init();
// base.rcoder.init(&filer);
//
//
// // base.put_str(0, mystr, mystr_len);
//
//
// // for (int i = -1000; i < 2000; i++) {
// // base.put_len(0, i*11+9);
// // base.put_num(0, i*7);
// // }
//
//
// }
// {
// FILE *fh = fopen(fname, "r");
// assert(fh);
// bool valid;
//
//
// FilerLoad filer(fh, &valid) ;
// assert(filer.is_valid());
// RecBase base ;
// BZERO(base);
// base.range_init();
// base.rcoder.init(&filer);
//
//
// // UCHAR str[1000];
// // UCHAR* p = base.get_str(0, str);
// // assert(0 == strcmp((const char*)str, (const char*)mystr));
// // assert(p == str + mystr_len);
//
//
// // for (int i = -1000; i < 2000; i++) {
// // int len = base.get_len(0);
// // assert(len == i*11+9);
// // long long num = base.get_num(0);
// // assert(num == i*7);
// // }
// // }
// }
// }

Expand Down
2 changes: 1 addition & 1 deletion xfile.hpp
Expand Up @@ -51,7 +51,7 @@ class XFileBase {
class XFileSave : private XFileBase {
FilerSave* filer;
void init();

public:
XFileSave(const char* filename);
~XFileSave();
Expand Down

0 comments on commit 7d599a7

Please sign in to comment.