summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-09-23 21:04:46 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-09-23 21:04:46 (GMT)
commit84540ce6d1708e98c152276f524c938435da804c (patch)
treebc9a3f4f5f57c8c1b41f88dafb11c9b107ad8623
parent308982f2359c32277144636d1f62cf20af1b0972 (diff)
downloadhdf5-84540ce6d1708e98c152276f524c938435da804c.zip
hdf5-84540ce6d1708e98c152276f524c938435da804c.tar.gz
hdf5-84540ce6d1708e98c152276f524c938435da804c.tar.bz2
[svn-r19477] Description:
Bring r19476 from trunk to 1.8 branch: Polish the vectorized memory <-> memory and memory <-> file I/O routines to speed them up a little bit (~10%) Tested on: FreeBSD/32 6.3 (duty) in debug mode (h5committested on trunk)
-rw-r--r--src/H5Dchunk.c14
-rw-r--r--src/H5Dcontig.c158
-rw-r--r--src/H5Defl.c34
-rw-r--r--src/H5V.c62
4 files changed, 127 insertions, 141 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 7e3bf90..9dcd0ec 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -4949,9 +4949,8 @@ H5D_nonexistent_readvv(const H5D_io_info_t *io_info,
H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */
H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */
hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */
- ssize_t bytes_processed = 0; /* Eventual return value */
size_t u, v; /* Local index variables */
- ssize_t ret_value; /* Return value */
+ ssize_t ret_value = 0; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5D_nonexistent_readvv)
@@ -4993,27 +4992,26 @@ H5D_nonexistent_readvv(const H5D_io_info_t *io_info,
/* Update source information */
chunk_len_arr[v] -= size;
- chunk_offset_arr[v] += size;
if(chunk_len_arr[v] == 0)
v++;
+ else
+ chunk_offset_arr[v] += size;
/* Update destination information */
mem_len_arr[u] -= size;
- mem_offset_arr[u] += size;
if(mem_len_arr[u] == 0)
u++;
+ else
+ mem_offset_arr[u] += size;
/* Increment number of bytes copied */
- bytes_processed += (ssize_t)size;
+ ret_value += (ssize_t)size;
} /* end for */
/* Update current sequence vectors */
*mem_curr_seq = u;
*chunk_curr_seq = v;
- /* Set return value */
- ret_value = bytes_processed;
-
done:
/* Release the fill buffer info, if it's been initialized */
if(fb_info_init && H5D_fill_term(&fb_info) < 0)
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index dcc7cdc..78c07e6 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -627,11 +627,9 @@ H5D_contig_readvv(const H5D_io_info_t *io_info,
const H5D_contig_storage_t *store_contig = &(io_info->store->contig); /* Contiguous storage info for this I/O operation */
unsigned char *buf = (unsigned char *)io_info->u.rbuf; /* Pointer to buffer to fill */
haddr_t addr; /* Actual address to read */
- size_t total_size = 0; /* Total size of sequence in bytes */
size_t size; /* Size of sequence in bytes */
- size_t u; /* Counting variable */
- size_t v; /* Counting variable */
- ssize_t ret_value; /* Return value */
+ size_t u, v; /* Counting variables */
+ ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
FUNC_ENTER_NOAPI(H5D_contig_readvv, FAIL)
#ifdef QAK
@@ -693,21 +691,21 @@ for(u = 0; u < mem_max_nseq; u++)
} /* end if */
else {
/* Allocate room for the data sieve buffer */
- if (NULL==(dset_contig->sieve_buf=H5FL_BLK_MALLOC(sieve_buf,dset_contig->sieve_buf_size)))
+ if(NULL == (dset_contig->sieve_buf = H5FL_BLK_MALLOC(sieve_buf, dset_contig->sieve_buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Determine the new sieve buffer size & location */
- dset_contig->sieve_loc=addr;
+ dset_contig->sieve_loc = addr;
/* Make certain we don't read off the end of the file */
if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(file, H5FD_MEM_DRAW)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size")
/* Set up the buffer parameters */
- max_data = store_contig->dset_size-dset_offset_arr[u];
+ max_data = store_contig->dset_size - dset_offset_arr[u];
/* Compute the size of the sieve buffer */
- H5_ASSIGN_OVERFLOW(dset_contig->sieve_size, MIN3(rel_eoa-dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size), hsize_t, size_t);
+ H5_ASSIGN_OVERFLOW(dset_contig->sieve_size, MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size), hsize_t, size_t);
/* Read the new sieve buffer */
if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf) < 0)
@@ -741,8 +739,8 @@ for(u = 0; u < mem_max_nseq; u++)
/* Check if we can actually hold the I/O request in the sieve buffer */
if(size>dset_contig->sieve_buf_size) {
/* Check for any overlap with the current sieve buffer */
- if((sieve_start>=addr && sieve_start<(contig_end+1))
- || ((sieve_end-1)>=addr && (sieve_end-1)<(contig_end+1))) {
+ if((sieve_start >= addr && sieve_start < (contig_end + 1))
+ || ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) {
/* Flush the sieve buffer, if it's dirty */
if(dset_contig->sieve_dirty) {
/* Write to file */
@@ -763,34 +761,34 @@ for(u = 0; u < mem_max_nseq; u++)
/* Flush the sieve buffer if it's dirty */
if(dset_contig->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0)
+ if(H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed")
/* Reset sieve buffer dirty flag */
- dset_contig->sieve_dirty=0;
+ dset_contig->sieve_dirty = 0;
} /* end if */
/* Determine the new sieve buffer size & location */
- dset_contig->sieve_loc=addr;
+ dset_contig->sieve_loc = addr;
/* Make certain we don't read off the end of the file */
if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(file, H5FD_MEM_DRAW)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size")
/* Only need this when resizing sieve buffer */
- max_data=store_contig->dset_size-dset_offset_arr[u];
+ max_data = store_contig->dset_size - dset_offset_arr[u];
/* Compute the size of the sieve buffer */
/* Don't read off the end of the file, don't read past the end of the data element and don't read more than the buffer size */
- H5_ASSIGN_OVERFLOW(dset_contig->sieve_size,MIN3(rel_eoa-dset_contig->sieve_loc,max_data,dset_contig->sieve_buf_size),hsize_t,size_t);
+ H5_ASSIGN_OVERFLOW(dset_contig->sieve_size, MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size), hsize_t, size_t);
/* Update local copies of sieve information */
- sieve_start=dset_contig->sieve_loc;
- sieve_size=dset_contig->sieve_size;
- sieve_end=sieve_start+sieve_size;
+ sieve_start = dset_contig->sieve_loc;
+ sieve_size = dset_contig->sieve_size;
+ sieve_end = sieve_start + sieve_size;
/* Read the new sieve buffer */
- if (H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0)
+ if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed")
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
@@ -804,18 +802,20 @@ for(u = 0; u < mem_max_nseq; u++)
/* Update memory information */
mem_len_arr[v] -= size;
- mem_offset_arr[v] += size;
if(mem_len_arr[v] == 0)
v++;
+ else
+ mem_offset_arr[v] += size;
/* Update file information */
dset_len_arr[u] -= size;
- dset_offset_arr[u] += size;
if(dset_len_arr[u] == 0)
u++;
+ else
+ dset_offset_arr[u] += size;
/* Increment number of bytes copied */
- total_size += size;
+ ret_value += (ssize_t)size;
} /* end for */
} /* end if */
else {
@@ -839,18 +839,20 @@ for(u = 0; u < mem_max_nseq; u++)
/* Update memory information */
mem_len_arr[v] -= size;
- mem_offset_arr[v] += size;
if(mem_len_arr[v] == 0)
v++;
+ else
+ mem_offset_arr[v] += size;
/* Update file information */
dset_len_arr[u] -= size;
- dset_offset_arr[u] += size;
if(dset_len_arr[u] == 0)
u++;
+ else
+ dset_offset_arr[u] += size;
/* Increment number of bytes copied */
- total_size += size;
+ ret_value += (ssize_t)size;
} /* end for */
} /* end else */
@@ -858,9 +860,6 @@ for(u = 0; u < mem_max_nseq; u++)
*dset_curr_seq = u;
*mem_curr_seq = v;
- /* Set return value */
- H5_ASSIGN_OVERFLOW(ret_value, total_size, size_t, ssize_t);
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_contig_readvv() */
@@ -894,11 +893,9 @@ H5D_contig_writevv(const H5D_io_info_t *io_info,
const H5D_contig_storage_t *store_contig = &(io_info->store->contig); /* Contiguous storage info for this I/O operation */
const unsigned char *buf = (const unsigned char *)io_info->u.wbuf; /* Pointer to buffer to fill */
haddr_t addr; /* Actual address to read */
- size_t total_size = 0; /* Size of sequence in bytes */
size_t size; /* Size of sequence in bytes */
- size_t u; /* Counting variable */
- size_t v; /* Counting variable */
- ssize_t ret_value; /* Return value */
+ size_t u, v; /* Counting variables */
+ ssize_t ret_value = 0; /* Return value (Size of sequence in bytes) */
FUNC_ENTER_NOAPI(H5D_contig_writevv, FAIL)
@@ -909,40 +906,40 @@ H5D_contig_writevv(const H5D_io_info_t *io_info,
HDassert(buf);
/* Check if data sieving is enabled */
- if(H5F_HAS_FEATURE(file,H5FD_FEAT_DATA_SIEVE)) {
- haddr_t sieve_start=HADDR_UNDEF, sieve_end=HADDR_UNDEF; /* Start & end locations of sieve buffer */
+ if(H5F_HAS_FEATURE(file, H5FD_FEAT_DATA_SIEVE)) {
+ haddr_t sieve_start = HADDR_UNDEF, sieve_end = HADDR_UNDEF; /* Start & end locations of sieve buffer */
haddr_t contig_end; /* End locations of block to write */
- size_t sieve_size=(size_t)-1; /* size of sieve buffer */
+ size_t sieve_size = (size_t)-1; /* size of sieve buffer */
haddr_t rel_eoa; /* Relative end of file address */
hsize_t max_data; /* Actual maximum size of data to cache */
/* Set offsets in sequence lists */
- u=*dset_curr_seq;
- v=*mem_curr_seq;
+ u = *dset_curr_seq;
+ v = *mem_curr_seq;
/* Stash local copies of these values */
- if(dset_contig->sieve_buf!=NULL) {
- sieve_start=dset_contig->sieve_loc;
- sieve_size=dset_contig->sieve_size;
- sieve_end=sieve_start+sieve_size;
+ if(dset_contig->sieve_buf != NULL) {
+ sieve_start = dset_contig->sieve_loc;
+ sieve_size = dset_contig->sieve_size;
+ sieve_end = sieve_start + sieve_size;
} /* end if */
/* Works through sequences as fast as possible */
- for(; u<dset_max_nseq && v<mem_max_nseq; ) {
+ for(; u < dset_max_nseq && v < mem_max_nseq; ) {
/* Choose smallest buffer to write */
- if(mem_len_arr[v]<dset_len_arr[u])
- size=mem_len_arr[v];
+ if(mem_len_arr[v] < dset_len_arr[u])
+ size = mem_len_arr[v];
else
- size=dset_len_arr[u];
+ size = dset_len_arr[u];
/* Compute offset on disk */
- addr=store_contig->dset_addr+dset_offset_arr[u];
+ addr = store_contig->dset_addr + dset_offset_arr[u];
/* Compute offset in memory */
buf = (const unsigned char *)io_info->u.wbuf + mem_offset_arr[v];
/* No data sieve buffer yet, go allocate one */
- if(dset_contig->sieve_buf==NULL) {
+ if(NULL == dset_contig->sieve_buf) {
/* Check if we can actually hold the I/O request in the sieve buffer */
if(size>dset_contig->sieve_buf_size) {
if(H5F_block_write(file, H5FD_MEM_DRAW, addr, size, io_info->dxpl_id, buf) < 0)
@@ -958,22 +955,22 @@ if(dset_contig->sieve_size > size)
#endif /* H5_CLEAR_MEMORY */
/* Determine the new sieve buffer size & location */
- dset_contig->sieve_loc=addr;
+ dset_contig->sieve_loc = addr;
/* Make certain we don't read off the end of the file */
if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(file, H5FD_MEM_DRAW)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size")
/* Set up the buffer parameters */
- max_data=store_contig->dset_size-dset_offset_arr[u];
+ max_data = store_contig->dset_size - dset_offset_arr[u];
/* Compute the size of the sieve buffer */
- H5_ASSIGN_OVERFLOW(dset_contig->sieve_size,MIN3(rel_eoa-dset_contig->sieve_loc,max_data,dset_contig->sieve_buf_size),hsize_t,size_t);
+ H5_ASSIGN_OVERFLOW(dset_contig->sieve_size, MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size), hsize_t, size_t);
/* Check if there is any point in reading the data from the file */
if(dset_contig->sieve_size>size) {
/* Read the new sieve buffer */
- if (H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0)
+ if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed")
} /* end if */
@@ -991,10 +988,10 @@ if(dset_contig->sieve_size > size)
} /* end if */
else {
/* Compute end of sequence to retrieve */
- contig_end=addr+size-1;
+ contig_end = addr + size - 1;
/* If entire write is within the sieve buffer, write it to the buffer */
- if(addr>=sieve_start && contig_end<sieve_end) {
+ if(addr >= sieve_start && contig_end < sieve_end) {
unsigned char *base_sieve_buf = dset_contig->sieve_buf + (addr - sieve_start);
/* Put the data into the sieve buffer */
@@ -1008,21 +1005,21 @@ if(dset_contig->sieve_size > size)
/* Check if we can actually hold the I/O request in the sieve buffer */
if(size>dset_contig->sieve_buf_size) {
/* Check for any overlap with the current sieve buffer */
- if((sieve_start>=addr && sieve_start<(contig_end+1))
- || ((sieve_end-1)>=addr && (sieve_end-1)<(contig_end+1))) {
+ if((sieve_start >= addr && sieve_start < (contig_end + 1))
+ || ((sieve_end - 1) >= addr && (sieve_end - 1) < (contig_end + 1))) {
/* Flush the sieve buffer, if it's dirty */
if(dset_contig->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0)
+ if(H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed")
/* Reset sieve buffer dirty flag */
- dset_contig->sieve_dirty=0;
+ dset_contig->sieve_dirty = 0;
} /* end if */
/* Force the sieve buffer to be re-read the next time */
- dset_contig->sieve_loc=HADDR_UNDEF;
- dset_contig->sieve_size=0;
+ dset_contig->sieve_loc = HADDR_UNDEF;
+ dset_contig->sieve_size = 0;
} /* end if */
/* Write directly from the user's buffer */
@@ -1032,8 +1029,8 @@ if(dset_contig->sieve_size > size)
/* Element size fits within the buffer size */
else {
/* Check if it is possible to (exactly) prepend or append to existing (dirty) sieve buffer */
- if(((addr+size)==sieve_start || addr==sieve_end) &&
- (size+sieve_size)<=dset_contig->sieve_buf_size &&
+ if(((addr + size) == sieve_start || addr == sieve_end) &&
+ (size + sieve_size) <= dset_contig->sieve_buf_size &&
dset_contig->sieve_dirty) {
/* Prepend to existing sieve buffer */
if((addr + size) == sieve_start) {
@@ -1066,36 +1063,36 @@ if(dset_contig->sieve_size > size)
/* Flush the sieve buffer if it's dirty */
if(dset_contig->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0)
+ if(H5F_block_write(file, H5FD_MEM_DRAW, sieve_start, sieve_size, io_info->dxpl_id, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed")
/* Reset sieve buffer dirty flag */
- dset_contig->sieve_dirty=0;
+ dset_contig->sieve_dirty = 0;
} /* end if */
/* Determine the new sieve buffer size & location */
- dset_contig->sieve_loc=addr;
+ dset_contig->sieve_loc = addr;
/* Make certain we don't read off the end of the file */
if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(file, H5FD_MEM_DRAW)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size")
/* Only need this when resizing sieve buffer */
- max_data=store_contig->dset_size-dset_offset_arr[u];
+ max_data = store_contig->dset_size - dset_offset_arr[u];
/* Compute the size of the sieve buffer */
/* Don't read off the end of the file, don't read past the end of the data element and don't read more than the buffer size */
- H5_ASSIGN_OVERFLOW(dset_contig->sieve_size,MIN3(rel_eoa-dset_contig->sieve_loc,max_data,dset_contig->sieve_buf_size),hsize_t,size_t);
+ H5_ASSIGN_OVERFLOW(dset_contig->sieve_size, MIN3(rel_eoa - dset_contig->sieve_loc, max_data, dset_contig->sieve_buf_size), hsize_t, size_t);
/* Update local copies of sieve information */
- sieve_start=dset_contig->sieve_loc;
- sieve_size=dset_contig->sieve_size;
- sieve_end=sieve_start+sieve_size;
+ sieve_start = dset_contig->sieve_loc;
+ sieve_size = dset_contig->sieve_size;
+ sieve_end = sieve_start + sieve_size;
/* Check if there is any point in reading the data from the file */
- if(dset_contig->sieve_size>size) {
+ if(dset_contig->sieve_size > size) {
/* Read the new sieve buffer */
- if (H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf)<0)
+ if(H5F_block_read(file, H5FD_MEM_DRAW, dset_contig->sieve_loc, dset_contig->sieve_size, io_info->dxpl_id, dset_contig->sieve_buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed")
} /* end if */
@@ -1111,18 +1108,20 @@ if(dset_contig->sieve_size > size)
/* Update memory information */
mem_len_arr[v] -= size;
- mem_offset_arr[v] += size;
if(mem_len_arr[v] == 0)
v++;
+ else
+ mem_offset_arr[v] += size;
/* Update file information */
dset_len_arr[u] -= size;
- dset_offset_arr[u] += size;
if(dset_len_arr[u] == 0)
u++;
+ else
+ dset_offset_arr[u] += size;
/* Increment number of bytes copied */
- total_size += size;
+ ret_value += (ssize_t)size;
} /* end for */
} /* end if */
else {
@@ -1146,18 +1145,20 @@ if(dset_contig->sieve_size > size)
/* Update memory information */
mem_len_arr[v] -= size;
- mem_offset_arr[v] += size;
if(mem_len_arr[v] == 0)
v++;
+ else
+ mem_offset_arr[v] += size;
/* Update file information */
dset_len_arr[u] -= size;
- dset_offset_arr[u] += size;
if(dset_len_arr[u] == 0)
u++;
+ else
+ dset_offset_arr[u] += size;
/* Increment number of bytes copied */
- total_size += size;
+ ret_value += (ssize_t)size;
} /* end for */
} /* end else */
@@ -1165,9 +1166,6 @@ if(dset_contig->sieve_size > size)
*dset_curr_seq = u;
*mem_curr_seq = v;
- /* Set return value */
- H5_ASSIGN_OVERFLOW(ret_value, total_size, size_t, ssize_t);
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_contig_writevv() */
diff --git a/src/H5Defl.c b/src/H5Defl.c
index b0233d4..87471f1 100644
--- a/src/H5Defl.c
+++ b/src/H5Defl.c
@@ -420,11 +420,9 @@ H5D_efl_readvv(const H5D_io_info_t *io_info,
const H5O_efl_t *efl = &(io_info->store->efl); /* Pointer to efl info */
unsigned char *buf; /* Pointer to buffer to write */
haddr_t addr; /* Actual address to read */
- size_t total_size = 0; /* Total size of sequence in bytes */
size_t size; /* Size of sequence in bytes */
- size_t u; /* Counting variable */
- size_t v; /* Counting variable */
- ssize_t ret_value; /* Return value */
+ size_t u, v; /* Counting variables */
+ ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
FUNC_ENTER_NOAPI_NOINIT(H5D_efl_readvv)
@@ -452,27 +450,26 @@ H5D_efl_readvv(const H5D_io_info_t *io_info,
/* Update memory information */
mem_len_arr[v] -= size;
- mem_offset_arr[v] += size;
if(mem_len_arr[v] == 0)
v++;
+ else
+ mem_offset_arr[v] += size;
/* Update file information */
dset_len_arr[u] -= size;
- dset_offset_arr[u] += size;
if(dset_len_arr[u] == 0)
u++;
+ else
+ dset_offset_arr[u] += size;
/* Increment number of bytes copied */
- total_size += size;
+ ret_value += (ssize_t)size;
} /* end for */
/* Update current sequence vectors */
*dset_curr_seq = u;
*mem_curr_seq = v;
- /* Set return value */
- H5_ASSIGN_OVERFLOW(ret_value, total_size, size_t, ssize_t);
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_efl_readvv() */
@@ -501,11 +498,9 @@ H5D_efl_writevv(const H5D_io_info_t *io_info,
const H5O_efl_t *efl = &(io_info->store->efl); /* Pointer to efl info */
const unsigned char *buf; /* Pointer to buffer to write */
haddr_t addr; /* Actual address to read */
- size_t total_size = 0; /* Total size of sequence in bytes */
size_t size; /* Size of sequence in bytes */
- size_t u; /* Counting variable */
- size_t v; /* Counting variable */
- ssize_t ret_value; /* Return value */
+ size_t u, v; /* Counting variables */
+ ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
FUNC_ENTER_NOAPI_NOINIT(H5D_efl_writevv)
@@ -533,27 +528,26 @@ H5D_efl_writevv(const H5D_io_info_t *io_info,
/* Update memory information */
mem_len_arr[v] -= size;
- mem_offset_arr[v] += size;
if(mem_len_arr[v] == 0)
v++;
+ else
+ mem_offset_arr[v] += size;
/* Update file information */
dset_len_arr[u] -= size;
- dset_offset_arr[u] += size;
if(dset_len_arr[u] == 0)
u++;
+ else
+ dset_offset_arr[u] += size;
/* Increment number of bytes copied */
- total_size += size;
+ ret_value += (ssize_t)size;
} /* end for */
/* Update current sequence vectors */
*dset_curr_seq = u;
*mem_curr_seq = v;
- /* Set return value */
- H5_ASSIGN_OVERFLOW(ret_value, total_size, size_t, ssize_t);
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_efl_writevv() */
diff --git a/src/H5V.c b/src/H5V.c
index 48fa9ab..979b591 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -1304,8 +1304,6 @@ H5V_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk,
* Programmer: Quincey Koziol
* Friday, May 2, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
ssize_t
@@ -1316,64 +1314,62 @@ H5V_memcpyvv(void *_dst,
{
unsigned char *dst; /* Destination buffer pointer */
const unsigned char *src; /* Source buffer pointer */
- size_t total_size=0; /* Total size of sequence in bytes */
size_t size; /* Size of sequence in bytes */
size_t u,v; /* Local index variables */
- ssize_t ret_value; /* Return value */
+ ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
FUNC_ENTER_NOAPI_NOFUNC(H5V_memcpyvv)
/* Sanity check */
- assert(_dst);
- assert(dst_curr_seq);
- assert(*dst_curr_seq<dst_max_nseq);
- assert(dst_len_arr);
- assert(dst_off_arr);
- assert(_src);
- assert(src_curr_seq);
- assert(*src_curr_seq<src_max_nseq);
- assert(src_len_arr);
- assert(src_off_arr);
+ HDassert(_dst);
+ HDassert(dst_curr_seq);
+ HDassert(*dst_curr_seq < dst_max_nseq);
+ HDassert(dst_len_arr);
+ HDassert(dst_off_arr);
+ HDassert(_src);
+ HDassert(src_curr_seq);
+ HDassert(*src_curr_seq < src_max_nseq);
+ HDassert(src_len_arr);
+ HDassert(src_off_arr);
/* Work through all the sequences */
- for(u=*dst_curr_seq, v=*src_curr_seq; u<dst_max_nseq && v<src_max_nseq; ) {
+ for(u = *dst_curr_seq, v = *src_curr_seq; u < dst_max_nseq && v < src_max_nseq; ) {
/* Choose smallest buffer to write */
- if(src_len_arr[v]<dst_len_arr[u])
- size=src_len_arr[v];
+ if(src_len_arr[v] < dst_len_arr[u])
+ size = src_len_arr[v];
else
- size=dst_len_arr[u];
+ size = dst_len_arr[u];
/* Compute offset on disk */
- dst=(unsigned char *)_dst+dst_off_arr[u];
+ dst = (unsigned char *)_dst + dst_off_arr[u];
/* Compute offset in memory */
- src=(const unsigned char *)_src+src_off_arr[v];
+ src = (const unsigned char *)_src + src_off_arr[v];
/* Copy data */
- HDmemcpy(dst,src,size);
+ HDmemcpy(dst, src, size);
/* Update source information */
- src_len_arr[v]-=size;
- src_off_arr[v]+=size;
- if(src_len_arr[v]==0)
+ src_len_arr[v] -= size;
+ if(0 == src_len_arr[v])
v++;
+ else
+ src_off_arr[v] += size;
/* Update destination information */
- dst_len_arr[u]-=size;
- dst_off_arr[u]+=size;
- if(dst_len_arr[u]==0)
+ dst_len_arr[u] -= size;
+ if(0 == dst_len_arr[u])
u++;
+ else
+ dst_off_arr[u] += size;
/* Increment number of bytes copied */
- total_size+=size;
+ ret_value += (ssize_t)size;
} /* end for */
/* Update current sequence vectors */
- *dst_curr_seq=u;
- *src_curr_seq=v;
-
- /* Set return value */
- H5_ASSIGN_OVERFLOW(ret_value,total_size,size_t,ssize_t);
+ *dst_curr_seq = u;
+ *src_curr_seq = v;
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_memcpyvv() */