diff --git a/src/OpenFOAM/global/profiling/profiling.C b/src/OpenFOAM/global/profiling/profiling.C index 85204b0092..43246de26f 100644 --- a/src/OpenFOAM/global/profiling/profiling.C +++ b/src/OpenFOAM/global/profiling/profiling.C @@ -37,16 +37,21 @@ Foam::profiling* Foam::profiling::pool_(0); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -Foam::profilingInformation* Foam::profiling::find(const string& name) +Foam::profilingInformation* Foam::profiling::find +( + const string& descr, + const label parentId +) { - StorageContainer::iterator iter = hash_.find(name); - return (iter != hash_.end() ? iter() : 0); + StorageContainer::iterator iter = hash_.find(Key(descr, parentId)); + return (iter.found() ? iter() : 0); } Foam::profilingInformation* Foam::profiling::store(profilingInformation *info) { - hash_.insert(info->description(), info); + // Profile information lookup is qualified by parent id + hash_.insert(Key(info->description(), info->parent().id()), info); return info; } @@ -174,7 +179,7 @@ Foam::profilingInformation* Foam::profiling::New { profilingInformation *parent = pool_->stack_.top(); - info = pool_->find(descr); + info = pool_->find(descr, parent->id()); if (!info) { info = pool_->store(new profilingInformation(descr, parent)); diff --git a/src/OpenFOAM/global/profiling/profiling.H b/src/OpenFOAM/global/profiling/profiling.H index e4d37bf589..c637946a21 100644 --- a/src/OpenFOAM/global/profiling/profiling.H +++ b/src/OpenFOAM/global/profiling/profiling.H @@ -87,10 +87,35 @@ public: private: - // Private typedefs + // Private classes, typedefs typedef profilingSysInfo sysInfo; - typedef HashPtrTable StorageContainer; + + //- Profile information lookup is qualified by parent id + typedef Tuple2 Key; + + //- Hashing for information lookup + class HashKey + : + public Hash + { + public: + + HashKey() + {} + + //- Hash qualified by the parent id to avoid collisions + unsigned operator()(const Key& key) const + { + return + ( + Hash()(key.first()) + + Hash