diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-05-12 18:40:29 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-05-12 18:40:29 (GMT) |
commit | 948a94f2be7d25720f9e505fbc2e13eda53bdc03 (patch) | |
tree | 6ddadec1f76446d89c9db966d856e87b4bfc7ea5 /src | |
parent | 820a21f61f0f35c03689e457f661c1f7b9296ea5 (diff) | |
download | hdf5-948a94f2be7d25720f9e505fbc2e13eda53bdc03.zip hdf5-948a94f2be7d25720f9e505fbc2e13eda53bdc03.tar.gz hdf5-948a94f2be7d25720f9e505fbc2e13eda53bdc03.tar.bz2 |
[svn-r8506] Purpose:
Code optimization
Description:
Eliminate many redundant lookups to check for no-op type conversion by
remembering that a type conversion path is the no-op path.
Also, don't allow non-no-op conversions which happen to be no-ops on a
particular machine (such as int<->long conversions on machines where int and
long are the same size and format, etc.) to replace the default no-op
conversion.
Platforms tested:
Solaris 2.7 (arabica)
FreeBSD 4.9 (sleipnir) w/parallel
Diffstat (limited to 'src')
-rw-r--r-- | src/H5T.c | 43 | ||||
-rw-r--r-- | src/H5Tpkg.h | 1 |
2 files changed, 25 insertions, 19 deletions
@@ -1195,8 +1195,10 @@ H5T_term_interface(void) } } - H5T_close (path->src); - H5T_close (path->dst); + if(path->src) + H5T_close (path->src); + if(path->dst) + H5T_close (path->dst); H5FL_FREE(H5T_path_t,path); H5T_g.path[i] = NULL; } @@ -2073,22 +2075,24 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, assert(name && *name); if (H5T_PERS_HARD==pers) { - /* Locate or create a new conversion path */ - if (NULL==(new_path=H5T_path_find(src, dst, name, func, dxpl_id))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to locate/allocate conversion path"); - - /* - * Notify all other functions to recalculate private data since some - * functions might cache a list of conversion functions. For - * instance, the compound type converter caches a list of conversion - * functions for the members, so adding a new function should cause - * the list to be recalculated to use the new function. - */ - for (i=0; i<H5T_g.npaths; i++) { - if (new_path != H5T_g.path[i]) - H5T_g.path[i]->cdata.recalc = TRUE; - } /* end for */ - + /* Only bother to register the path if it's not a no-op path (for this machine) */ + if(H5T_cmp(src, dst)) { + /* Locate or create a new conversion path */ + if (NULL==(new_path=H5T_path_find(src, dst, name, func, dxpl_id))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to locate/allocate conversion path"); + + /* + * Notify all other functions to recalculate private data since some + * functions might cache a list of conversion functions. For + * instance, the compound type converter caches a list of conversion + * functions for the members, so adding a new function should cause + * the list to be recalculated to use the new function. + */ + for (i=0; i<H5T_g.npaths; i++) { + if (new_path != H5T_g.path[i]) + H5T_g.path[i]->cdata.recalc = TRUE; + } /* end for */ + } /* end if */ } else { /* Add function to end of soft list */ if (H5T_g.nsoft>=H5T_g.asoft) { @@ -3851,6 +3855,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, #endif H5E_clear(); /*ignore the error*/ } + H5T_g.path[0]->is_noop = TRUE; H5T_g.npaths = 1; } @@ -4075,7 +4080,7 @@ H5T_path_noop(const H5T_path_t *p) assert(p); - FUNC_LEAVE_NOAPI(p->is_hard && 0==H5T_cmp(p->src, p->dst)); + FUNC_LEAVE_NOAPI(p->is_noop || (p->is_hard && 0==H5T_cmp(p->src, p->dst))); } /* end H5T_path_noop() */ diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 4f16ca8..7d891e7 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -67,6 +67,7 @@ struct H5T_path_t { H5T_t *dst; /*destination data type ID */ H5T_conv_t func; /*data conversion function */ hbool_t is_hard; /*is it a hard function? */ + hbool_t is_noop; /*is it the noop conversion? */ H5T_stats_t stats; /*statistics for the conversion */ H5T_cdata_t cdata; /*data for this function */ }; |