Changeset 785

Show
Ignore:
Timestamp:
04/28/06 11:39:49 (4 years ago)
Author:
ahu
Message:

replace ugly cache insertion/deleting code by nice alternative from Joaquin Lopez Munoz

Location:
trunk/pdns/pdns
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/syncres.cc

    r784 r785  
    685685          ne.d_qtype=QType(0); 
    686686           
    687           pair<negcache_t::iterator, bool> res=s_negcache.insert(ne); 
    688           if(!res.second) { 
    689             s_negcache.erase(res.first); 
    690             s_negcache.insert(ne); 
    691           } 
     687          replacing_insert(s_negcache, ne); 
    692688          negindic=true; 
    693689        } 
     
    728724          ne.d_qtype=qtype; 
    729725          if(qtype.getCode()) {  // prevents us from blacking out a whole domain 
    730             pair<negcache_t::iterator, bool> res=s_negcache.insert(ne); 
    731             if(!res.second) { 
    732               s_negcache.erase(res.first); 
    733               s_negcache.insert(ne); 
    734             } 
     726            replacing_insert(s_negcache, ne); 
    735727          } 
    736728          negindic=true; 
  • trunk/pdns/pdns/syncres.hh

    r780 r785  
    412412 
    413413extern RecursorStats g_stats; 
     414 
     415 
     416template<typename Index> 
     417std::pair<typename Index::iterator,bool> 
     418replacing_insert(Index& i,const typename Index::value_type& x) 
     419{ 
     420  std::pair<typename Index::iterator,bool> res=i.insert(x); 
     421  if(!res.second)res.second=i.replace(res.first,x); 
     422  return res; 
     423} 
     424 
    414425#endif