Make hash value const
This commit is contained in:
parent
7f3f70f766
commit
f5407e398a
@ -138,7 +138,7 @@ static FASTCOVER_segment_t FASTCOVER_selectSegment(const FASTCOVER_ctx_t *ctx,
|
|||||||
*/
|
*/
|
||||||
while (activeSegment.end < end) {
|
while (activeSegment.end < end) {
|
||||||
/* Get hash value of current dmer */
|
/* Get hash value of current dmer */
|
||||||
size_t index = FASTCOVER_hash8PtrToIndex(ctx->samples + activeSegment.end, parameters.f);
|
const size_t index = FASTCOVER_hash8PtrToIndex(ctx->samples + activeSegment.end, parameters.f);
|
||||||
/* Add frequency of this index to score */
|
/* Add frequency of this index to score */
|
||||||
activeSegment.score += freqs[index];
|
activeSegment.score += freqs[index];
|
||||||
/* Increment end of segment */
|
/* Increment end of segment */
|
||||||
@ -146,7 +146,7 @@ static FASTCOVER_segment_t FASTCOVER_selectSegment(const FASTCOVER_ctx_t *ctx,
|
|||||||
/* If the window is now too large, drop the first position */
|
/* If the window is now too large, drop the first position */
|
||||||
if (activeSegment.end - activeSegment.begin == dmersInK + 1) {
|
if (activeSegment.end - activeSegment.begin == dmersInK + 1) {
|
||||||
/* Get hash value of the dmer to be eliminated from active segment */
|
/* Get hash value of the dmer to be eliminated from active segment */
|
||||||
size_t delIndex = FASTCOVER_hash8PtrToIndex(ctx->samples + activeSegment.begin, parameters.f);
|
const size_t delIndex = FASTCOVER_hash8PtrToIndex(ctx->samples + activeSegment.begin, parameters.f);
|
||||||
/* Subtract frequency of this index from score */
|
/* Subtract frequency of this index from score */
|
||||||
activeSegment.score -= freqs[delIndex];
|
activeSegment.score -= freqs[delIndex];
|
||||||
/* Increment start of segment */
|
/* Increment start of segment */
|
||||||
@ -163,7 +163,7 @@ static FASTCOVER_segment_t FASTCOVER_selectSegment(const FASTCOVER_ctx_t *ctx,
|
|||||||
U32 newEnd = bestSegment.begin;
|
U32 newEnd = bestSegment.begin;
|
||||||
U32 pos;
|
U32 pos;
|
||||||
for (pos = bestSegment.begin; pos != bestSegment.end; ++pos) {
|
for (pos = bestSegment.begin; pos != bestSegment.end; ++pos) {
|
||||||
size_t index = FASTCOVER_hash8PtrToIndex(ctx->samples + pos, parameters.f);
|
const size_t index = FASTCOVER_hash8PtrToIndex(ctx->samples + pos, parameters.f);
|
||||||
U32 freq = freqs[index];
|
U32 freq = freqs[index];
|
||||||
if (freq != 0) {
|
if (freq != 0) {
|
||||||
newBegin = MIN(newBegin, pos);
|
newBegin = MIN(newBegin, pos);
|
||||||
@ -177,7 +177,7 @@ static FASTCOVER_segment_t FASTCOVER_selectSegment(const FASTCOVER_ctx_t *ctx,
|
|||||||
/* Half the frequency of hash value of each dmer covered by the chosen segment. */
|
/* Half the frequency of hash value of each dmer covered by the chosen segment. */
|
||||||
U32 pos;
|
U32 pos;
|
||||||
for (pos = bestSegment.begin; pos != bestSegment.end; ++pos) {
|
for (pos = bestSegment.begin; pos != bestSegment.end; ++pos) {
|
||||||
size_t i = FASTCOVER_hash8PtrToIndex(ctx->samples + pos, parameters.f);
|
const size_t i = FASTCOVER_hash8PtrToIndex(ctx->samples + pos, parameters.f);
|
||||||
freqs[i] = freqs[i]/2;
|
freqs[i] = freqs[i]/2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,7 +244,7 @@ static void FASTCOVER_getFrequency(U32 *freqs, unsigned f, FASTCOVER_ctx_t *ctx)
|
|||||||
size_t currSampleEnd = ctx->offsets[i+1];
|
size_t currSampleEnd = ctx->offsets[i+1];
|
||||||
start = currSampleStart;
|
start = currSampleStart;
|
||||||
while (start + f < currSampleEnd) {
|
while (start + f < currSampleEnd) {
|
||||||
size_t dmerIndex = FASTCOVER_hash8PtrToIndex(ctx->samples + start, f);
|
const size_t dmerIndex = FASTCOVER_hash8PtrToIndex(ctx->samples + start, f);
|
||||||
/* if no dmer with same hash value has been seen in current sample */
|
/* if no dmer with same hash value has been seen in current sample */
|
||||||
if (inCurrSample[dmerIndex] == 0) {
|
if (inCurrSample[dmerIndex] == 0) {
|
||||||
inCurrSample[dmerIndex]++;
|
inCurrSample[dmerIndex]++;
|
||||||
|
Loading…
Reference in New Issue
Block a user