Review Request: Optimize loading speed of tables

Thorsten Zachmann t.zachmann at
Wed Dec 14 11:18:03 UTC 2011

This is an automatically generated e-mail. To reply, visit:

(Updated Dec. 14, 2011, 11:18 a.m.)

Review request for Calligra.


Optimize formula parsing by a factor of 2-4
This optimizes formula parsing by a factor of 2-4. The file
loads now in 25 instead of 30 seconds.
The patch tries to avoid creating QString objects when not necessary and reuse
QString object when possible. The reduces the number of allocations quite a lot.
Also implicit casts of 'x' and "foo" are avoided where ever possible as these
are also quite expensive.
e.g. some of the easy optimizations are
if (QString::operator[0] == '$')
is better written as
if (QString::operator[0] == QChar('$', 0)
as this can be optimized already be the compiler and thus reduces the stuff needed
Also initialize class members in initialization list of the constructor where possible
as this avoids copying the data a second time which is also expensive if it is e.g. a
Additionally to the speed up also the formula parsing now can recognice a escaped " in
a formula and parsing of error codes has been updated to follow ODF 1.2. This fixes the
failing unit tests in TestFormula.
Added unit test for decodeFormula.

This addresses bug 288959.


  tables/DependencyManager.cpp 2313e46 
  tables/Formula.h 5a996f3 
  tables/Formula.cpp e79ae1b 
  tables/Region.h 261beb4 
  tables/Region.cpp 1920ca9 
  tables/Util.h b1879fb 
  tables/Util.cpp ac03f0f 
  tables/tests/CMakeLists.txt 9cc51db 
  tables/tests/TestUtil.h PRE-CREATION 
  tables/tests/TestUtil.cpp PRE-CREATION 



Run the changes against ~ 500 docs and compared the pre patch/after values returned by scan and decodeFormula. The results of decodeFormula where all the same pre/after. The result of scan has changed due to the fixed error and string handling. 


Thorsten Zachmann

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the calligra-devel mailing list