X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FMippleton.hh;h=7058eccf76214911933a61a7d3fca5a07de4fcf9;hp=95d3f21577e6e9d444e56cf6a4fb33f50e421b73;hb=72d4af22710317acffab861421c4364b1780b6fe;hpb=493ddb59a8620b49dfa0ff62ce93395ebfd02e86 diff --git a/src/Moof/Mippleton.hh b/src/Moof/Mippleton.hh index 95d3f21..7058ecc 100644 --- a/src/Moof/Mippleton.hh +++ b/src/Moof/Mippleton.hh @@ -38,25 +38,26 @@ * after the last interested code releases its hold on the object. */ -#include +#include #include - namespace Mf { template class Mippleton { - typedef std::pair ptr_value_t; - typedef std::pair ptr_map_pair_t; - typedef std::map ptr_map_t; + typedef std::pair ptr_value_t; + typedef std::pair ptr_map_pair_t; + typedef stlplus::hash ptr_map_t; + //typedef std::map ptr_map_t; - static ptr_map_t ptrs_; - std::string name_; + static ptr_map_t ptrs_; + std::string name_; public: - explicit Mippleton(const std::string& name) : name_(name) {} + explicit Mippleton(const std::string& name) : + name_(name) {} inline const std::string& getName() const { @@ -65,11 +66,11 @@ public: inline static T* retain(const std::string& name) { - typename ptr_map_t::iterator it; + typename ptr_map_t::iterator it = ptrs_.find(name); - if ((it = ptrs_.find(name)) != ptrs_.end()) + if (it != ptrs_.end()) { - (*it).second.first++; + ++((*it).second.first); return (*it).second.second; } else @@ -84,10 +85,10 @@ public: { typename ptr_map_t::iterator it; - if ((it = ptrs_.find(name)) != ptrs_.end() && -(*it).second.first == 0) + if ((it = ptrs_.find(name)) != ptrs_.end() && --(*it).second.first == 0) { delete (*it).second.second; - ptrs_.erase(it); + ptrs_.erase((*it).first); } } @@ -98,7 +99,9 @@ public: }; template -std::map > Mippleton::ptrs_; +stlplus::hash< std::string,std::pair,hash_string > +//std::map< std::string,std::pair > + Mippleton::ptrs_; } // namespace Mf