Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexta committed Dec 25, 2012
1 parent 0826156 commit 181c750
Show file tree
Hide file tree
Showing 29 changed files with 170 additions and 608 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ cmake_install.cmake
install_manifest.txt
*.cxx
nbproject
*.a
*.orig
*.*~
50 changes: 18 additions & 32 deletions Compressor/Codec/Codecs/BWT/divsuf/divsufsort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ construct_BWT(const uint8_t *T, int32_t *SA,

int32_t
divsufsort(const uint8_t *T, int32_t *SA, int32_t n) {
int32_t *bucket_A, *bucket_B;
int32_t m;
int32_t err = 0;

Expand All @@ -312,27 +311,19 @@ divsufsort(const uint8_t *T, int32_t *SA, int32_t n) {
return 0;
}

bucket_A = new int32_t [BUCKET_A_SIZE];
bucket_B = new int32_t [BUCKET_B_SIZE];
int32_t bucket_A [BUCKET_A_SIZE];
int32_t bucket_B [BUCKET_B_SIZE];

/* Suffixsort. */
if ((bucket_A != NULL) && (bucket_B != NULL)) {
m = sort_typeBstar(T, SA, bucket_A, bucket_B, n);
construct_SA(T, SA, bucket_A, bucket_B, n, m);
} else {
err = -2;
}

delete[] bucket_B;
delete[] bucket_A;
m = sort_typeBstar(T, SA, bucket_A, bucket_B, n);
construct_SA(T, SA, bucket_A, bucket_B, n, m);

return err;
}

int32_t
divbwt(const uint8_t *T, uint8_t *U, int32_t *A, int32_t n) {
int32_t *B;
int32_t *bucket_A, *bucket_B;
int32_t m, pidx, i;

/* Check arguments. */
Expand All @@ -348,29 +339,24 @@ divbwt(const uint8_t *T, uint8_t *U, int32_t *A, int32_t n) {
if ((B = A) == NULL) {
B = new int32_t [ (n + 1)];
}
bucket_A = new int32_t [BUCKET_A_SIZE];
bucket_B = new int32_t [BUCKET_B_SIZE];

int32_t bucket_A [BUCKET_A_SIZE];
int32_t bucket_B [BUCKET_B_SIZE];

/* Burrows-Wheeler Transform. */
if ((B != NULL) && (bucket_A != NULL) && (bucket_B != NULL)) {
m = sort_typeBstar(T, B, bucket_A, bucket_B, n);
pidx = construct_BWT(T, B, bucket_A, bucket_B, n, m);

/* Copy to output string. */
U[0] = T[n - 1];
for (i = 0; i < pidx; ++i) {
U[i + 1] = (uint8_t) B[i];
}
for (i += 1; i < n; ++i) {
U[i] = (uint8_t) B[i];
}
pidx += 1;
} else {
pidx = -2;
m = sort_typeBstar(T, B, bucket_A, bucket_B, n);
pidx = construct_BWT(T, B, bucket_A, bucket_B, n, m);

/* Copy to output string. */
U[0] = T[n - 1];
for (i = 0; i < pidx; ++i) {
U[i + 1] = (uint8_t) B[i];
}
for (i += 1; i < n; ++i) {
U[i] = (uint8_t) B[i];
}
pidx += 1;

delete[] bucket_B;
delete[] bucket_A;
if (A == NULL)
delete[] B;

Expand Down
24 changes: 13 additions & 11 deletions Compressor/Codec/Codecs/BWT/divsuf/sssort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ ss_pivot(const uint8_t *Td, const int32_t *PA, int32_t *first, int32_t *last) {
return ss_median5(Td, PA, first, first + t, middle, last - 1 - t, last - 1);
}
}

t >>= 3;
first = ss_median3(Td, PA, first, first + t, first + (t << 1));
middle = ss_median3(Td, PA, middle - t, middle, middle + t);
Expand Down Expand Up @@ -316,11 +317,10 @@ ss_mintrosort(const uint8_t *T, const int32_t *PA,
const uint8_t *Td;
int32_t *a, *b, *c, *d, *e, *f;
int32_t s, t;
int32_t ssize;
int32_t limit;
int32_t limit = ss_ilg(last - first);
int32_t v, x = 0;

for (ssize = 0, limit = ss_ilg(last - first);;) {
for (;;) {

if ((last - first) <= SS_INSERTIONSORT_THRESHOLD) {
if (1 < (last - first)) {
Expand All @@ -340,7 +340,7 @@ ss_mintrosort(const uint8_t *T, const int32_t *PA,
if (limit < 0) {
for (a = first + 1, v = Td[PA[*first]]; a < last; ++a) {
if ((x = Td[PA[*a]]) != v) {
if (1 < (a - first)) {
if (a > first) {
break;
}
v = x;
Expand All @@ -358,7 +358,7 @@ ss_mintrosort(const uint8_t *T, const int32_t *PA,
first = a, limit = -1;
}
} else {
if (1 < (last - a)) {
if (last > a) {
stack.push(StackDataT(first, a, depth + 1, ss_ilg(a - first)));
first = a, limit = -1;
} else {
Expand All @@ -376,8 +376,9 @@ ss_mintrosort(const uint8_t *T, const int32_t *PA,
/* partition */
for (b = first; (++b < last) && ((x = Td[PA[*b]]) == v);) {
}

if (((a = b) < last) && (x < v)) {
for (; (++b < last) && ((x = Td[PA[*b]]) <= v);) {
while ((++b < last) && ((x = Td[PA[*b]]) <= v)) {
if (x == v) {
swap(*b, *a);
++a;
Expand All @@ -394,15 +395,15 @@ ss_mintrosort(const uint8_t *T, const int32_t *PA,
}
}
}
for (; b < c;) {
while (b < c) {
swap(*b, *c);
for (; (++b < c) && ((x = Td[PA[*b]]) <= v);) {
while ((++b < c) && ((x = Td[PA[*b]]) <= v)) {
if (x == v) {
swap(*b, *a);
++a;
}
}
for (; (b < --c) && ((x = Td[PA[*c]]) >= v);) {
while ((b < --c) && ((x = Td[PA[*c]]) >= v)) {
if (x == v) {
swap(*c, *d);
--d;
Expand Down Expand Up @@ -486,7 +487,8 @@ ss_rotate(int32_t *first, int32_t *middle, int32_t *last) {
int32_t *a, *b, t;
int32_t l, r;
l = middle - first, r = last - middle;
for (; (0 < l) && (0 < r);) {

while ((l > 0) && (r > 0)) {
if (l == r) {
ss_blockswap(first, middle, l);
break;
Expand Down Expand Up @@ -825,7 +827,7 @@ ss_swapmerge(const uint8_t *T, const int32_t *PA,
if (*rm < 0) {
*rm = ~*rm;
if (first < lm) {
for (; *--l < 0;) {
while (*--l < 0) {
}
next |= 4;
}
Expand Down
10 changes: 6 additions & 4 deletions Compressor/Codec/Codecs/BWT/divsuf/trsort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ tr_partition(const int32_t *ISAd,
for (b = middle - 1; (++b < last) && ((x = ISAd[*b]) == v);) {
}
if (((a = b) < last) && (x < v)) {
for (; (++b < last) && ((x = ISAd[*b]) <= v);) {
while ((++b < last) && ((x = ISAd[*b]) <= v)) {
if (x == v) {
swap(*b, *a);
++a;
Expand All @@ -271,15 +271,17 @@ tr_partition(const int32_t *ISAd,
}
}
}
for (; b < c;) {

while (b < c) {
swap(*b, *c);
for (; (++b < c) && ((x = ISAd[*b]) <= v);) {
while ((++b < c) && ((x = ISAd[*b]) <= v)) {
if (x == v) {
swap(*b, *a);
++a;
}
}
for (; (b < --c) && ((x = ISAd[*c]) >= v);) {

while ((b < --c) && ((x = ISAd[*c]) >= v)) {
if (x == v) {
swap(*c, *d);
--d;
Expand Down
52 changes: 46 additions & 6 deletions GUI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,49 @@
cmake_minimum_required(VERSION 2.8)

add_subdirectory(CompressorThread)
add_subdirectory(DataUnitsToQString)
add_subdirectory(Face)
add_subdirectory(FileList)
add_subdirectory(SettingsPanels)
add_subdirectory(StatInfoW)

find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})

set(${project}_face_SRC
compressSettingsPanel.cpp
compressorThread.cpp
dataUnitsToQString.cpp
decompressSetingsPanel.cpp
face.cpp
fileList.cpp
statInfoW.cpp
)

set(${project}_face_HEADERS
compressSettingsPanel.h
compressorThread.h
decompressSetingsPanel.h
face.h
fileList.h
statInfoW.h
)

set(${project}_face_FORMS
face.ui
)


QT4_WRAP_UI(${project}_face_FORMS_HEADERS ${${project}_face_FORMS})
QT4_WRAP_CPP(${project}_face_HEADERS_MOC ${${project}_face_HEADERS})

include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR})


add_library(${project}_face STATIC
${${project}_face_SRC}
${${project}_face_FORMS_HEADERS}
${${project}_face_HEADERS_MOC}
)

target_link_libraries(${project}_face
${QT_LIBRARIES}
${project}_compressor
)

25 changes: 0 additions & 25 deletions GUI/CompressorThread/CMakeLists.txt

This file was deleted.

17 changes: 0 additions & 17 deletions GUI/DataUnitsToQString/CMakeLists.txt

This file was deleted.

41 changes: 0 additions & 41 deletions GUI/Face/CMakeLists.txt

This file was deleted.

25 changes: 0 additions & 25 deletions GUI/FileList/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 181c750

Please sign in to comment.