One thing that might be an optimization for you is to keep a cache of line positions. You could do it as others have suggested by caching all of the line offsets or, if you're not interested in reading all of the lines, but just a few in localized areas, just cache the offset of the few lines that you read so that if you've read line 57 and need to read line 63, you can start reading from the cached line position for line 57. Of course, there will be some overhead to lookup these cached line positions, but it may outweigh the cost of reading all of the lines over again or storing offsets for all of the lines. It all depends on your application.
In reply to Re: Fast way to read from file
by duff
in thread Fast way to read from file
by Hena
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |