From: malaterre Date: Mon, 18 Oct 2004 02:31:58 +0000 (+0000) Subject: ENH: Try to reuse result from a map query, eventhough this is optimised we should... X-Git-Tag: Version0.6.bp~54 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2fcc61952e680d58840c7ab1d2f09bbab7eff84f;p=gdcm.git ENH: Try to reuse result from a map query, eventhough this is optimised we should reuse result when possible --- diff --git a/src/gdcmDict.cxx b/src/gdcmDict.cxx index 8662d151..a8a80f2b 100644 --- a/src/gdcmDict.cxx +++ b/src/gdcmDict.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDict.cxx,v $ Language: C++ - Date: $Date: 2004/10/18 02:17:06 $ - Version: $Revision: 1.46 $ + Date: $Date: 2004/10/18 02:31:58 $ + Version: $Revision: 1.47 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -191,11 +191,12 @@ bool Dict::ReplaceEntry(DictEntry *newEntry) * @param key (group|element) * @return false if Dicom Dictionary Entry doesn't exist */ -bool Dict::RemoveEntry(TagKey key) +bool Dict::RemoveEntry(TagKey const & key) { - if(KeyHt.count(key) == 1) + TagKeyHT::const_iterator it = KeyHt.find(key); + if(it != KeyHt.end()) { - DictEntry* entryToDelete = KeyHt.find(key)->second; + DictEntry* entryToDelete = it->second; if ( entryToDelete ) { @@ -235,11 +236,12 @@ bool Dict::RemoveEntry (uint16_t group, uint16_t element) */ DictEntry* Dict::GetDictEntryByName(TagName const & name) { - if ( !NameHt.count(name)) + TagNameHT::const_iterator it = NameHt.find(name); + if ( it == NameHt.end() ) { return 0; } - return NameHt.find(name)->second; + return it->second; } /** @@ -251,11 +253,12 @@ DictEntry* Dict::GetDictEntryByName(TagName const & name) DictEntry* Dict::GetDictEntryByNumber(uint16_t group, uint16_t element) { TagKey key = DictEntry::TranslateToKey(group, element); - if ( !KeyHt.count(key) ) + TagKeyHT::const_iterator it = KeyHt.find(key); + if ( it == KeyHt.end() ) { return 0; } - return KeyHt.find(key)->second; + return it->second; } /** diff --git a/src/gdcmDict.h b/src/gdcmDict.h index b6152da2..8f1c8379 100644 --- a/src/gdcmDict.h +++ b/src/gdcmDict.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDict.h,v $ Language: C++ - Date: $Date: 2004/10/18 02:17:06 $ - Version: $Revision: 1.20 $ + Date: $Date: 2004/10/18 02:31:58 $ + Version: $Revision: 1.21 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -59,7 +59,7 @@ public: // Entries bool AddNewEntry (DictEntry *newEntry); bool ReplaceEntry(DictEntry *newEntry); - bool RemoveEntry (TagKey key); + bool RemoveEntry (TagKey const & key); bool RemoveEntry (uint16_t group, uint16_t element); // Tag diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 53c1ff3c..5993675b 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.cxx,v $ Language: C++ - Date: $Date: 2004/10/18 02:17:07 $ - Version: $Revision: 1.39 $ + Date: $Date: 2004/10/18 02:31:58 $ + Version: $Revision: 1.40 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -141,10 +141,10 @@ EntryNamesByCatMap * DictSet::GetPubDictEntryNamesByCategory() * @param name Symbolic name that be used as identifier of the newly * created dictionary. */ -Dict *DictSet::LoadDictFromFile(std::string const & fileName, +Dict *DictSet::LoadDictFromFile(std::string const & filename, DictKey const & name) { - Dict *newDict = new Dict(fileName); + Dict *newDict = new Dict(filename); AppendDict(newDict, name); return newDict;