 <p>Most likely the function is not the bottleneck, but the fact that you are calling it 12 million times :-)</p> <p>An obvious improvement is having a variable </p> <pre><code>const char* file_pos = file + pos; </code></pre> <p>simplifying every single access. You don't say how tline is implemented; if a line never contains more than two words then you can probably make it faster by having two std::string members instead of an array. </p>