From: malaterre Date: Mon, 11 Jul 2005 15:20:46 +0000 (+0000) Subject: ENH: NEW FEATURE: TagKey is now a union of two uint16_t instead of string this greatl... X-Git-Tag: Version1.2.bp~323 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=fdca8d2cc7f1a716e591540de386c88dabbf6031;p=gdcm.git ENH: NEW FEATURE: TagKey is now a union of two uint16_t instead of string this greatly improve speed --- diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index 9e02d6e3..30d087ed 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmCommon.h,v $ Language: C++ - Date: $Date: 2005/07/11 15:08:18 $ - Version: $Revision: 1.72 $ + Date: $Date: 2005/07/11 15:20:46 $ + Version: $Revision: 1.73 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -85,6 +85,12 @@ typedef unsigned int uint32_t; #endif #include +#define FASTTAGKEY 0 + +// FIXME: Should rewrite this: +#if FASTTAGKEY +#include +#endif #if defined(_MSC_VER) && (_MSC_VER == 1200) /* ostream operator for std::string since VS6 does not provide it*/ #include @@ -119,7 +125,36 @@ GDCM_EXPORT extern const std::string GDCM_UNREAD; /// We'll fix the mess up -without any change in the API- as soon as the bench /// marks are fully performed. +#if FASTTAGKEY +typedef union { + uint16_t tab[2]; + uint32_t tagkey; + } TagKey; +/* ostream operator for TagKey */ +inline std::ostream& operator<<(std::ostream& _O, TagKey _val) +{ + return ( _O << std::ios::hex << _val.tab[0] + << "|" << std::ios::hex << _val.tab[1] ); +}; +inline bool operator==(TagKey _self, TagKey _val) +{ + return _self.tagkey == _val.tagkey; +}; +inline bool operator<(TagKey _self, TagKey _val) +{ + return _self.tagkey < _val.tagkey; +}; +// FIXME +// This one is clearly weird, see gdcmDocument:918 +inline TagKey operator+(TagKey _self, TagKey _val) +{ + TagKey r; + r.tagkey = _self.tagkey + _val.tagkey; + return r; +}; +#else typedef std::string TagKey; +#endif #if defined(_MSC_VER) && (_MSC_VER == 1200) // Doing everything within gdcm namespace to avoid polluting 3d party software inline std::ostream& operator<<(std::ostream& _O, std::string _val) diff --git a/src/gdcmDictEntry.cxx b/src/gdcmDictEntry.cxx index 0c542ef7..3e88c55f 100644 --- a/src/gdcmDictEntry.cxx +++ b/src/gdcmDictEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictEntry.cxx,v $ Language: C++ - Date: $Date: 2005/06/24 10:55:58 $ - Version: $Revision: 1.50 $ + Date: $Date: 2005/07/11 15:20:46 $ + Version: $Revision: 1.51 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -100,9 +100,16 @@ TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem) // Let's try to shorten it ! //return Util::Format("%04x|%04x", group, elem); // too much time ! +#if FASTTAGKEY + TagKey r; + r.tab[0] = group; + r.tab[1] = elem; + return r; +#else char res[10]; sprintf(res,"%04x|%04x", group, elem); return res; +#endif } //----------------------------------------------------------------------------- diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 779d1b0e..e1c795cd 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.cxx,v $ Language: C++ - Date: $Date: 2005/07/11 14:53:16 $ - Version: $Revision: 1.66 $ + Date: $Date: 2005/07/11 15:20:46 $ + Version: $Revision: 1.67 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -116,10 +116,17 @@ DictEntry *DictSet::NewVirtualDictEntry( uint16_t group, // // const std::string tag = DictEntry::TranslateToKey(group,elem) // + "#" + vr + "#" + vm + "#" + name; +#if FASTTAGKEY + // FIXME + TagKey tag; + tag.tab[0] = group; + tag.tab[1] = elem; +#else char res[10]; sprintf(res,"%04x|%04x", group, elem); TagKey tag = res; tag += "#" + vr + "#" + vm + "#" + name; +#endif TagKeyHT::iterator it;