我正在编写涉及对大型 fasta 文件进行迭代的性能关键代码,其中某些行可能多达数十万个字符。到目前为止我一直这样做的方式是:
#include <ifstream>
ifstream file("file_path.fasta");
int c;
while ((c = file.get()) != EOF) {
// do stuff with c
}
file.close();
逐字符遍历文件并对当前字符进行操作。我怀疑这是最高效的方法吗? ?我是否应该采用 here 或 here 中提到的一些方法?