Skip to content

Commit 55d66d2

Browse files
authored
consolidate loops
1 parent 35163ab commit 55d66d2

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

Diff for: src/subcommand/rna_main.cpp

+9-16
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,18 @@ int32_t main_rna(int32_t argc, char** argv) {
251251
return 1;
252252
}
253253

254-
// taken from https://stackoverflow.com/a/20446239/
255-
for (auto & filename: transcript_filenames) {
254+
// taken from https://stackoverflow.com/a/64794991/
255+
for (const auto & f : {std::cref(transcript_filenames), std::cref(intron_filenames)}) {
256256

257-
if (filename.size() >= gz_suffix.size() &&
258-
filename.compare(filename.size() - gz_suffix.size(), gz_suffix.size(), gz_suffix) == 0) {
257+
for (auto filename : f.get()) {
259258

260-
cerr << "[vg rna] ERROR: Transcript file " << filename << " appears to be gzipped. Decompress it before use." << endl;
261-
return 1;
262-
}
263-
}
264-
265-
// I wish this wasn't copy-pasted but I don't know where a function would go
266-
for (auto & filename: intron_filenames) {
259+
// taken from https://stackoverflow.com/a/20446239/
260+
if (filename.size() >= gz_suffix.size() &&
261+
filename.compare(filename.size() - gz_suffix.size(), gz_suffix.size(), gz_suffix) == 0) {
267262

268-
if (filename.size() >= gz_suffix.size() &&
269-
filename.compare(filename.size() - gz_suffix.size(), gz_suffix.size(), gz_suffix) == 0) {
270-
271-
cerr << "[vg rna] ERROR: Intron file " << filename << " appears to be gzipped. Decompress it before use." << endl;
272-
return 1;
263+
cerr << "[vg rna] ERROR: Annotation file " << filename << " appears to be gzipped. Decompress it before use." << endl;
264+
return 1;
265+
}
273266
}
274267
}
275268

0 commit comments

Comments
 (0)