Skip to content

Commit 6602044

Browse files
committed
readability-magic-numbers
1 parent 48d69aa commit 6602044

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/linmemalign.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,16 @@ LinearMemoryAligner::~LinearMemoryAligner()
132132
// refactoring: scorematrix_create should be private, called at construction time
133133
auto LinearMemoryAligner::scorematrix_create(int64_t match, int64_t mismatch) -> int64_t *
134134
{
135+
static constexpr auto last_row = matrix_size - 1; // 'N'
136+
static constexpr auto last_column = matrix_size - 1; // 'N'
135137
auto * newscorematrix = (int64_t *) xmalloc(matrix_size * matrix_size * sizeof(int64_t));
136138

137139
for (auto i = 0; i < matrix_size; i++)
138140
{
139141
for (auto j = 0; j < matrix_size; j++)
140142
{
141143
int64_t value = 0;
142-
if (opt_n_mismatch && ((i == 15) || (j == 15)))
144+
if (opt_n_mismatch && ((i == last_row) || (j == last_column)))
143145
{
144146
value = mismatch;
145147
}
@@ -715,6 +717,7 @@ auto LinearMemoryAligner::alignstats(char * cigar,
715717
int64_t * _nwmismatches,
716718
int64_t * _nwgaps) -> void
717719
{
720+
static constexpr auto is_N = 15; // 4-bit code for 'N' or 'n'
718721
a_seq = _a_seq;
719722
b_seq = _b_seq;
720723

@@ -745,8 +748,8 @@ auto LinearMemoryAligner::alignstats(char * cigar,
745748
{
746749
nwscore += subst_score(a_pos, b_pos);
747750

748-
if (opt_n_mismatch && ((chrmap_4bit[(int) (a_seq[a_pos])] == 15) ||
749-
(chrmap_4bit[(int) (b_seq[b_pos])] == 15)))
751+
if (opt_n_mismatch && ((chrmap_4bit[(int) (a_seq[a_pos])] == is_N) ||
752+
(chrmap_4bit[(int) (b_seq[b_pos])] == is_N)))
750753
{
751754
nwmismatches++;
752755
}

0 commit comments

Comments
 (0)