diff options
author | Eike Rathke <erack@redhat.com> | 2015-11-03 13:03:39 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-11-03 13:37:27 +0100 |
commit | 3fd400c6b67f8f9b5527720ad148c1f428a59ab2 (patch) | |
tree | 41952244eae591cc10c5f496e1cc87a3e2bc07cb /sc | |
parent | 93d61feaf55cfe4484581e1985435cd1439d6f41 (diff) |
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
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/cellvalue.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/cellvalue.cxx | 9 |
2 files changed, 6 insertions, 7 deletions
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx index 915bdee11f07..7ac6a87182f4 100644 --- a/sc/inc/cellvalue.hxx +++ b/sc/inc/cellvalue.hxx @@ -123,10 +123,6 @@ struct SC_DLLPUBLIC ScRefCellValue /** * 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 ); diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx index 69032970b467..f0fe714aed7b 100644 --- a/sc/source/core/data/cellvalue.cxx +++ b/sc/source/core/data/cellvalue.cxx @@ -495,9 +495,7 @@ ScRefCellValue::ScRefCellValue( const ScRefCellValue& r ) : meType(r.meType), mf ScRefCellValue::ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos ) { - const ScRefCellValue& rCell = rDoc.GetRefCellValue(rPos); - meType = rCell.meType; - mfValue = rCell.mfValue; + assign( rDoc, rPos); } ScRefCellValue::~ScRefCellValue() @@ -593,6 +591,11 @@ bool ScRefCellValue::equalsWithoutFormat( const ScRefCellValue& r ) const 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; mfValue = r.mfValue; // largest member of union return *this; |