diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-07 15:10:19 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-07 15:10:19 +0200 |
commit | 1bf442e1ccc99f875bcb8eadfe328d5c3d86edba (patch) | |
tree | 351b49deeb1cb78d8655d33c56b8ff6016632dd2 | |
parent | 567ad2330ec8be4f23014a0a3e8dce11bcd1eada (diff) | |
download | mupdf-1bf442e1ccc99f875bcb8eadfe328d5c3d86edba.tar.xz |
Optimize file seeks that can be done within the buffered data.
-rw-r--r-- | fitz/stm_read.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fitz/stm_read.c b/fitz/stm_read.c index 4a81b9cd..59f06433 100644 --- a/fitz/stm_read.c +++ b/fitz/stm_read.c @@ -173,6 +173,16 @@ fz_seek(fz_stream *stm, int offset, int whence) offset = fz_tell(stm) + offset; whence = 0; } + if (whence == 0) + { + unsigned char *p = stm->wp - (stm->pos - offset); + if (p >= stm->bp && p <= stm->wp) + { + stm->rp = p; + stm->eof = 0; + return; + } + } stm->seek(stm, offset, whence); stm->eof = 0; } |