Mercurial > octave
changeset 25657:db326f3aacf4
Improve fread speed by a further 2.5X when SKIP parameter used (bug #54100).
* oct-stream.cc (stream::fread): Use C++ seekg and tellg versus C seek and tell
for a 2.5X speedup.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 22 Jul 2018 20:40:02 -0700 |
parents | fbc2730a653b |
children | 0812413a0bb7 |
files | libinterp/corefcn/oct-stream.cc |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc Sun Jul 22 15:37:57 2018 -0700 +++ b/libinterp/corefcn/oct-stream.cc Sun Jul 22 20:40:02 2018 -0700 @@ -6609,10 +6609,10 @@ off_t eof_pos = 0; if (skip != 0 && is && ! is.eof ()) { - off_t orig_pos = tell (); - seek (0, SEEK_END); - eof_pos = tell (); - seek (orig_pos, SEEK_SET); + off_t orig_pos = is.tellg (); + is.seekg (0, is.end); + eof_pos = is.tellg (); + is.seekg (orig_pos, is.beg); } std::list <void *> input_buf_list; @@ -6646,13 +6646,13 @@ { // Attempt to skip. // If skip would move past EOF, position at EOF. - off_t orig_pos = tell (); + off_t orig_pos = is.tellg (); off_t remaining = eof_pos - orig_pos; if (remaining < skip) - seek (0, SEEK_END); + is.seekg (0, is.end); else - seek (skip, SEEK_CUR); + is.seekg (skip, is.cur); if (! is) break;