Right now, pasting formulae into sheets is roughly an $O(n^2)$ operation due to the linear search loop on the entire calcChain being run for each formula update.
This PR uses a Set instead of the calcChain array to optimise the search operation into $O(log n)$ - hence converting the entire operation to $O(nlogn)$ more or less. The set is computed only once for the entire operation, which makes paste operations less than ~15 rows more expensive, but for more rows it is many orders of magnitude faster.
Here are my findings for the calculation processing time (blue is the current code in master, red is the code in this branch) -
Resolves #486
Right now, pasting formulae into sheets is roughly an $O(n^2)$ operation due to the linear search loop on the entire
calcChain
being run for each formula update.This PR uses a
Set
instead of thecalcChain
array to optimise the search operation into $O(log n)$ - hence converting the entire operation to $O(nlogn)$ more or less. The set is computed only once for the entire operation, which makes paste operations less than ~15 rows more expensive, but for more rows it is many orders of magnitude faster.Here are my findings for the calculation processing time (blue is the current code in master, red is the code in this branch) -