[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source
Eike Rathke
erack at redhat.com
Tue Nov 3 04:38:15 PST 2015
sc/inc/cellvalue.hxx | 4 ----
sc/source/core/data/cellvalue.cxx | 10 ++++++----
2 files changed, 6 insertions(+), 8 deletions(-)
New commits:
commit 3fd400c6b67f8f9b5527720ad148c1f428a59ab2
Author: Eike Rathke <erack at redhat.com>
Date: Tue Nov 3 13:03:39 2015 +0100
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
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 915bdee..7ac6a87 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 6903297..f0fe714 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;
commit 93d61feaf55cfe4484581e1985435cd1439d6f41
Author: Eike Rathke <erack at redhat.com>
Date: Mon Nov 2 19:05:24 2015 +0100
remove superfluous call to clear() in ScRefCellValue dtor
Change-Id: Iea7788f985e2c5dc7a96eab711bf7d13732ab86e
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index c63f493..6903297 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -502,7 +502,6 @@ ScRefCellValue::ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos )
ScRefCellValue::~ScRefCellValue()
{
- clear();
}
void ScRefCellValue::clear()
More information about the Libreoffice-commits
mailing list