[x] ~20% of execution time: The CellIndex function is called for every cell and is surprisingly expensive.
So if we can make both of these two things super efficient, maybe there is a 2x speedup available.
For the second one, the cost is coming in through both Sprintf calls. I think in colName it could be reduced to a string addition using the + operator. You could avoid the Sprintf call in CellIndex by making it return the row part and the column part seperately and templating them into the cell when you finally sprintf them.
Things are already looking quite good.
The easiest things to make faster I think would be:
So if we can make both of these two things super efficient, maybe there is a 2x speedup available.
For the second one, the cost is coming in through both Sprintf calls. I think in
colName
it could be reduced to a string addition using the+
operator. You could avoid the Sprintf call in CellIndex by making it return the row part and the column part seperately and templating them into the cell when you finally sprintf them.