~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/regex_policy/module.cc

  • Committer: Olaf van der Spek
  • Date: 2011-06-27 15:52:45 UTC
  • mto: This revision was merged to the branch mainline in revision 2351.
  • Revision ID: olafvdspek@gmail.com-20110627155245-eguw4snf4l3pf6mc
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
250
250
void CheckItem::setCachedResult(bool result)
251
251
{
252
252
  // TODO: make the mutex per-cache
253
 
  CheckMap *old_cache;
254
 
  CheckMap *new_cache;
255
253
  boost::mutex::scoped_lock lock(check_cache_mutex, boost::defer_lock);
256
254
  lock.lock();
257
255
 
258
256
  // Copy the current one
259
 
  if (*check_cache)
260
 
  {
261
 
    new_cache= new CheckMap(**check_cache);
262
 
  }
263
 
  else
264
 
  {
265
 
    new_cache= new CheckMap();
266
 
  }
 
257
  CheckMap* new_cache= *check_cache ? new CheckMap(**check_cache) : new CheckMap;
267
258
 
268
259
  // Update it
269
260
  (*new_cache)[key]= result;
270
261
  // Replace old
271
 
  old_cache= *check_cache;
 
262
  CheckMap* old_cache= *check_cache;
272
263
  *check_cache= new_cache;
273
264
 
274
265
  lock.unlock();
275
266
  has_cached_result= true;
276
267
  cached_result= result;
277
268
 
278
 
  if (old_cache)
279
 
  {
280
 
    delete old_cache;
281
 
  }
 
269
  delete old_cache;
282
270
}
283
271
 
284
272
} /* namespace regex_policy */