Do not optimize unnecessarily!
The cost of comparison is 1-2 cycles, and, as mentioned in Art, it can be optimized by the compiler. The cost is absolutely negligible compared to the cost of reading from a file. The performance of your program will in any case be related to I / O (reading or reading disks depending on whether the file is displayed in memory).
In this case, you must write code to make it easy to maintain.
source share