diff options
Diffstat (limited to 'archival/libarchive/bz/blocksort.c')
-rw-r--r-- | archival/libarchive/bz/blocksort.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/archival/libarchive/bz/blocksort.c b/archival/libarchive/bz/blocksort.c index effaa152a..7c5b6c552 100644 --- a/archival/libarchive/bz/blocksort.c +++ b/archival/libarchive/bz/blocksort.c | |||
@@ -1022,16 +1022,15 @@ void mainSort(EState* state) | |||
1022 | * arr1[0 .. nblock-1] holds sorted order | 1022 | * arr1[0 .. nblock-1] holds sorted order |
1023 | */ | 1023 | */ |
1024 | static NOINLINE | 1024 | static NOINLINE |
1025 | void BZ2_blockSort(EState* state) | 1025 | int32_t BZ2_blockSort(EState* state) |
1026 | { | 1026 | { |
1027 | /* In original bzip2 1.0.4, it's a parameter, but 30 | 1027 | /* In original bzip2 1.0.4, it's a parameter, but 30 |
1028 | * (which was the default) should work ok. */ | 1028 | * (which was the default) should work ok. */ |
1029 | enum { wfact = 30 }; | 1029 | enum { wfact = 30 }; |
1030 | unsigned i; | 1030 | unsigned i; |
1031 | int32_t origPtr = origPtr; | ||
1031 | 1032 | ||
1032 | if (state->nblock < 10000) { | 1033 | if (state->nblock >= 10000) { |
1033 | fallbackSort(state); | ||
1034 | } else { | ||
1035 | /* Calculate the location for quadrant, remembering to get | 1034 | /* Calculate the location for quadrant, remembering to get |
1036 | * the alignment right. Assumes that &(block[0]) is at least | 1035 | * the alignment right. Assumes that &(block[0]) is at least |
1037 | * 2-byte aligned -- this should be ok since block is really | 1036 | * 2-byte aligned -- this should be ok since block is really |
@@ -1050,24 +1049,25 @@ void BZ2_blockSort(EState* state) | |||
1050 | * of whether or not we use the main sort or fallback sort. | 1049 | * of whether or not we use the main sort or fallback sort. |
1051 | */ | 1050 | */ |
1052 | state->budget = state->nblock * ((wfact-1) / 3); | 1051 | state->budget = state->nblock * ((wfact-1) / 3); |
1053 | |||
1054 | mainSort(state); | 1052 | mainSort(state); |
1055 | if (state->budget < 0) { | 1053 | if (state->budget >= 0) |
1056 | fallbackSort(state); | 1054 | goto good; |
1057 | } | ||
1058 | } | 1055 | } |
1056 | fallbackSort(state); | ||
1057 | good: | ||
1059 | 1058 | ||
1060 | #if BZ_LIGHT_DEBUG | 1059 | #if BZ_LIGHT_DEBUG |
1061 | state->origPtr = -1; | 1060 | origPtr = -1; |
1062 | #endif | 1061 | #endif |
1063 | for (i = 0; i < state->nblock; i++) { | 1062 | for (i = 0; i < state->nblock; i++) { |
1064 | if (state->ptr[i] == 0) { | 1063 | if (state->ptr[i] == 0) { |
1065 | state->origPtr = i; | 1064 | origPtr = i; |
1066 | break; | 1065 | break; |
1067 | } | 1066 | } |
1068 | } | 1067 | } |
1069 | 1068 | ||
1070 | AssertH(state->origPtr != -1, 1003); | 1069 | AssertH(origPtr != -1, 1003); |
1070 | return origPtr; | ||
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | 1073 | ||