From: wolf Date: Wed, 2 Feb 2000 14:37:08 +0000 (+0000) Subject: One optimization, one bugfix for possible problems. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef7b91831ea413407c2457d326b96688431caafa;p=dealii-svn.git One optimization, one bugfix for possible problems. git-svn-id: https://svn.dealii.org/trunk@2328 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/smartpointer.h b/deal.II/base/include/base/smartpointer.h index c60294ec5d..e684b6354c 100644 --- a/deal.II/base/include/base/smartpointer.h +++ b/deal.II/base/include/base/smartpointer.h @@ -152,7 +152,13 @@ SmartPointer::~SmartPointer () { template -SmartPointer & SmartPointer::operator = (T *tt) { +SmartPointer & SmartPointer::operator = (T *tt) +{ + // optimize if no real action is + // requested + if (t == tt) + return *this; + if (t) t->unsubscribe(); t = tt; @@ -163,7 +169,14 @@ SmartPointer & SmartPointer::operator = (T *tt) { template -SmartPointer & SmartPointer::operator = (const SmartPointer& tt) { +SmartPointer & SmartPointer::operator = (const SmartPointer& tt) +{ + // if objects on the left and right + // hand side of the operator= are + // the same, then this is a no-op + if (&tt == this) + return *this; + if (t) t->unsubscribe(); t = static_cast(tt);