Revision 85efba9...

Go back to digest for 18th December 2011

Optimization in Office

Thorsten Zachmann committed changes in [calligra/tables-optimize-loading-zachman] /:

Optimize formula parsing by a factor of 2-4

This optimizes formula parsing by a factor of 2-4. The file
www.worldmapper.org%2Fdata%2Funderlying%2FWorldmapper_U3_hdr%304_tables1-22.ods
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
otherwise.

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
QString.

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 code also contains some debug code to check that the new results is actually the
same as the old results. Due to the fixes in the formula parsing that might no longer
be true for some of the formulas. This check will be removed in the next commit so that
it is easy to get it back if more testing is needed. When running against a set of ods,
xls and xlsx it showed no difference before fixing the formula parsing.

File Changes

Added 2 files
  • /tests
  •   tables/TestUtil.cpp
  •   tables/TestUtil.h
Modified 8 files
  •   tables/Cell.cpp
  •   tables/Formula.cpp
  •   tables/Formula.h
  •   tables/Region.cpp
  •   tables/Region.h
  •   tables/Util.cpp
  •   tables/Util.h
  •   tables/tests/CMakeLists.txt
10 files changed in total