summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1997-10-08 22:11:46 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1997-10-08 22:11:46 (GMT)
commitcdb316b7e0b247977d667edac7b98486e3a9b46c (patch)
tree694437667c157739f46921fed4fd4df9975270cd /src/H5F.c
parent2721bb475869900135de0fe14cde6ac1d4d73d8d (diff)
downloadhdf5-cdb316b7e0b247977d667edac7b98486e3a9b46c.zip
hdf5-cdb316b7e0b247977d667edac7b98486e3a9b46c.tar.gz
hdf5-cdb316b7e0b247977d667edac7b98486e3a9b46c.tar.bz2
[svn-r117] Added "seek position caching" code to shared file-records, which trimmed 20%
off the run-time for the current tests. (4.77s down to 3.89s)
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 88e4581..25cb336 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1295,14 +1295,20 @@ H5F_block_read (H5F_t *f, haddr_t addr, size_t size, void *buf)
if (0==size) return 0;
addr += f->shared->file_create_parms.userblock_size;
- if (H5F_SEEK (f->shared->file_handle, addr)<0) {
- /* low-level seek failure */
- HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL);
- }
+ /* Check for switching file access operations or mis-placed seek offset */
+ if(f->shared->last_op!=OP_READ || f->shared->f_cur_off!=addr)
+ {
+ f->shared->last_op=OP_READ;
+ if (H5F_SEEK (f->shared->file_handle, addr)<0) {
+ /* low-level seek failure */
+ HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL);
+ } /* end if */
+ } /* end if */
if (H5F_READ (f->shared->file_handle, buf, size)<0) {
/* low-level read failure */
HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL);
}
+ f->shared->f_cur_off=addr+size;
FUNC_LEAVE (SUCCEED);
}
@@ -1343,14 +1349,22 @@ H5F_block_write (H5F_t *f, haddr_t addr, size_t size, void *buf)
/* no write intent */
HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL);
}
- if (H5F_SEEK (f->shared->file_handle, addr)<0) {
- /* low-level seek failure */
- HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL);
- }
+
+ /* Check for switching file access operations or mis-placed seek offset */
+ if(f->shared->last_op!=OP_WRITE || f->shared->f_cur_off!=addr)
+ {
+ f->shared->last_op=OP_WRITE;
+ if (H5F_SEEK (f->shared->file_handle, addr)<0) {
+ /* low-level seek failure */
+ HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL);
+ }
+ } /* end if */
+
if (H5F_WRITE (f->shared->file_handle, buf, size)<0) {
/* low-level write failure */
HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL);
}
+ f->shared->f_cur_off=addr+size;
FUNC_LEAVE (SUCCEED);
}