getline while reading a file vs reading whole file and then splitting based on newline character

后端 未结 6 1392
孤街浪徒
孤街浪徒 2020-12-16 17:09

I want to process each line of a file on a hard-disk now. Is it better to load a file as a whole and then split on basis of newline character (using boost), or is it better

6条回答
  •  执念已碎
    2020-12-16 17:55

    The OS will read a whole block of data (depending on how the disk is formatted, typically 4-8k at a time) and do some of the buffering for you. Let the OS take care of it for you, and read the data in the way that makes sense for your program.

提交回复
热议问题