Kaydet (Commit) 3fd400c6 authored tarafından Eike Rathke's avatar Eike Rathke

implement assignment in only one place

... and comment on what to do if we really wanted a copy-swap-idiom.
The need to doc comment about not to use assign() after default ctor is
also gone with the temporary swap.

Change-Id: I2a49091b2a41cf155e912e3c373dbbe81c7f9737
üst 93d61fea
...@@ -123,10 +123,6 @@ struct SC_DLLPUBLIC ScRefCellValue ...@@ -123,10 +123,6 @@ struct SC_DLLPUBLIC ScRefCellValue
/** /**
* Take cell value from specified position in specified document. * Take cell value from specified position in specified document.
*
* Avoid the sequence of ScRefCellValue() default ctor followed by assign()
* as it results in performance penalty, use the
* ScRefCellValue(ScDocument&,const ScAddress&) ctor instead.
*/ */
void assign( ScDocument& rDoc, const ScAddress& rPos ); void assign( ScDocument& rDoc, const ScAddress& rPos );
......
...@@ -495,9 +495,7 @@ ScRefCellValue::ScRefCellValue( const ScRefCellValue& r ) : meType(r.meType), mf ...@@ -495,9 +495,7 @@ ScRefCellValue::ScRefCellValue( const ScRefCellValue& r ) : meType(r.meType), mf
ScRefCellValue::ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos ) ScRefCellValue::ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos )
{ {
const ScRefCellValue& rCell = rDoc.GetRefCellValue(rPos); assign( rDoc, rPos);
meType = rCell.meType;
mfValue = rCell.mfValue;
} }
ScRefCellValue::~ScRefCellValue() ScRefCellValue::~ScRefCellValue()
...@@ -593,6 +591,11 @@ bool ScRefCellValue::equalsWithoutFormat( const ScRefCellValue& r ) const ...@@ -593,6 +591,11 @@ bool ScRefCellValue::equalsWithoutFormat( const ScRefCellValue& r ) const
ScRefCellValue& ScRefCellValue::operator= ( const ScRefCellValue& r ) ScRefCellValue& ScRefCellValue::operator= ( const ScRefCellValue& r )
{ {
// So we *could* have a copy-swap-idiom here for exception-safety if we had
// to slow down things.. but then implement an explicit move-ctor and pass
// r by-value instead of manually creating a temporary so the compiler can
// take advantage. And initialize
// ScRefCellValue(ScDocument&,const ScAddress&) with default ctor.
meType = r.meType; meType = r.meType;
mfValue = r.mfValue; // largest member of union mfValue = r.mfValue; // largest member of union
return *this; return *this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment