summaryrefslogtreecommitdiff
path: root/fitz/stm_read.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-07 15:10:19 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-07 15:10:19 +0200
commit1bf442e1ccc99f875bcb8eadfe328d5c3d86edba (patch)
tree351b49deeb1cb78d8655d33c56b8ff6016632dd2 /fitz/stm_read.c
parent567ad2330ec8be4f23014a0a3e8dce11bcd1eada (diff)
downloadmupdf-1bf442e1ccc99f875bcb8eadfe328d5c3d86edba.tar.xz
Optimize file seeks that can be done within the buffered data.
Diffstat (limited to 'fitz/stm_read.c')
-rw-r--r--fitz/stm_read.c10
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;
}