cperformanceiofseek

Efficiency reading chars of a file


I train myself in building a compiler. When I read the file I sometimes need to look a few characters ahead of my current position to know which token I have to generate.

There are two options that come to my mind in that case:

Which one of these options is more efficient? Which would you prefer?


Solution

  • Thanks for the comments. My decision is to just read the file entirely first and then later check if I run into any performance issues.