From 1bf442e1ccc99f875bcb8eadfe328d5c3d86edba Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 7 Apr 2011 15:10:19 +0200 Subject: Optimize file seeks that can be done within the buffered data. --- fitz/stm_read.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'fitz/stm_read.c') 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; } -- cgit v1.2.3