summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-03-10 09:04:57 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-03-10 11:09:47 +0000
commit94eed3f5bb675d60239414ad2289bde7cc4d4f8e (patch)
treeff4bfbf8b7557a5046370bba8e91f1a9cf07c502 /sc/inc
parent0307413a287b07c08206169e2645261373e19bb1 (diff)
Fix issue in re-use of ScTokenArray objects from a TokenPool
The TokenPool::operator[] is used to initialise and take into use an object from the pool. Which is a fascinating thing as such and probably not entirely in good style. Anyway, the objects in the pool are of type ScTokenArray, a class derived from FormulaTokenArray. The operator[] called the FormulaTokenArray::Clear() function to initialise the object. This left the fields added in ScTokenArray uninitialised, having whatever value the previous use of the object had set. Which of course is bad. In practice, this showed up in the handling of formulas in the .xls input filter. If an earlier (or the first?) formula had happened to be one for which we don't want to use OpenCL, the meVectorState of its ScTokenArray object in the pool had been set to FormulaVectorDisabled. When the same pool object was later re-used for another formula, it kept that same meVectorState, even if there was no reason to. Thus formula groups that should have been OpenCL accelerated weren't. This can have a significant impact on performance of document loading and recalculation for large documents. I added a function to ScTokenArray to clear (initialise) such an object, both the FormulaTokenArray part and the ScTokenArray-specific part, and call that instead. This fixes the issue. I named the added function ClearScTokenArray() to make it clear that it is a separate function. Sure, possibly Clear() should be made into a virtual of FormulaTokenArry and overridden in ScTokenArray, and the overriding Clear() would first call the base class's Clear(). But I can't be sure that there aren't other calls of FormulaTokenArray::Clear() that *must* mean the base class one. Better safe than sorry. And of course, I did *not* want to name the function in ScTokenArray also "Clear()", like in the base class, without it being virtual. That is horrible style in my opinion, even if there certainly is precedence for such even in the very same classes, i.e. the Clone() function... Change-Id: I0e0e13e5ca705603005a1e0a46866f095cd2ac4d Reviewed-on: https://gerrit.libreoffice.org/14824 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/tokenarray.hxx1
1 files changed, 1 insertions, 0 deletions
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 54f1d1e65c1e..cd32952c47eb 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -57,6 +57,7 @@ public:
/// Assignment with references to FormulaToken entries (not copied!)
ScTokenArray( const ScTokenArray& );
virtual ~ScTokenArray();
+ void ClearScTokenArray();
ScTokenArray* Clone() const; /// True copy!
// An estimate of the number of cells referenced by the token array