]> Creatis software - gdcm.git/commitdiff
ENH: NEW FEATURE: TagKey is now a union of two uint16_t instead of string this greatl...
authormalaterre <malaterre>
Mon, 11 Jul 2005 15:20:46 +0000 (15:20 +0000)
committermalaterre <malaterre>
Mon, 11 Jul 2005 15:20:46 +0000 (15:20 +0000)
src/gdcmCommon.h
src/gdcmDictEntry.cxx
src/gdcmDictSet.cxx

index 9e02d6e3067ea1603f6b453212c83a9f16a49fcb..30d087ed1037403b88d2ceaa3151d66b507e8019 100644 (file)
@@ -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 <string>
+#define FASTTAGKEY 0
+
+// FIXME: Should rewrite this:
+#if FASTTAGKEY
+#include <iostream>
+#endif
 #if defined(_MSC_VER) && (_MSC_VER == 1200)
 /* ostream operator for std::string since VS6 does not provide it*/
 #include <iostream>
@@ -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)
index 0c542ef7e3e7e97f45b00b1d25626e04677eb4ff..3e88c55f0a4f9728c6c8e7831abe734b7f4e18b3 100644 (file)
@@ -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
 }
 
 //-----------------------------------------------------------------------------
index 779d1b0e669eb7bd794f04f73072706343f2676f..e1c795cd28a80a96fd5a4781e70ab6ae8bcbef2a 100644 (file)
@@ -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;