Skip to content

Commit f476133

Browse files
smithlab_os.cpp: Using preprocessor directives to ensure that a variable only used in an assert only exists when the assert does
1 parent 5645567 commit f476133

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

smithlab_os.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ read_fastq_file(const char *filename,
232232
vector<char> scr;
233233
vector<vector<char> > scrs;
234234
bool first_line = true;
235+
// ADS: preprocessor stuff below is because is_sequence_line is only
236+
// used with asserts; consider removing variable
237+
#ifndef NDEBUG
235238
bool is_sequence_line = false;
239+
#endif
236240
size_t line_count = 0;
237241
while (!in.eof()) {
238242
char buffer[INPUT_BUFFER_SIZE + 1];
@@ -261,12 +265,16 @@ read_fastq_file(const char *filename,
261265
name = name.substr(name.find_first_not_of("@ "));
262266
s = "";
263267
scr.clear();
268+
#ifndef NDEBUG
264269
is_sequence_line = true;
270+
#endif
265271
}
266272
if (is_fastq_sequence_line(line_count)) {
267273
assert(is_sequence_line);
268274
s += buffer;
275+
#ifndef NDEBUG
269276
is_sequence_line = false;
277+
#endif
270278
}
271279
if (is_fastq_score_name_line(line_count)) {
272280
if (buffer[0] != '+')
@@ -319,7 +327,11 @@ void read_fastq_file(const char *filename, vector<string> &names,
319327

320328
string s, name, scr;
321329
bool first_line = true;
330+
// ADS: preprocessor stuff below is because is_sequence_line is only
331+
// used with asserts; consider removing variable
332+
#ifndef NDEBUG
322333
bool is_sequence_line = false;
334+
#endif
323335
size_t line_count = 0;
324336
while (!in.eof()) {
325337
char buffer[INPUT_BUFFER_SIZE + 1];
@@ -346,12 +358,16 @@ void read_fastq_file(const char *filename, vector<string> &names,
346358
first_line = false;
347359
name = buffer;
348360
name = name.substr(name.find_first_not_of("@ "));
361+
#ifndef NDEBUG
349362
is_sequence_line = true;
363+
#endif
350364
}
351365
if (is_fastq_sequence_line(line_count)) {
352366
assert(is_sequence_line);
353367
s = buffer;
368+
#ifndef NDEBUG
354369
is_sequence_line = false;
370+
#endif
355371
}
356372
if (is_fastq_score_name_line(line_count)) {
357373
if (buffer[0] != '+')

0 commit comments

Comments
 (0)