From 963a0585358ac3a583655a4db66ed126e7232787 Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Sun, 3 Mar 2024 02:39:50 +0100 Subject: [PATCH] Optimize getSharedFormula to avoid runtime.duffcopy (#1837) --- cell.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cell.go b/cell.go index 5d547e8..3f1dd48 100644 --- a/cell.go +++ b/cell.go @@ -1655,8 +1655,10 @@ func parseSharedFormula(dCol, dRow int, orig []byte) (res string, start int) { // Note that this function not validate ref tag to check the cell whether in // allow range reference, and always return origin shared formula. func getSharedFormula(ws *xlsxWorksheet, si int, cell string) string { - for _, r := range ws.SheetData.Row { - for _, c := range r.C { + for row := 0; row < len(ws.SheetData.Row); row++ { + r := &ws.SheetData.Row[row] + for column := 0; column < len(r.C); column++ { + c := &r.C[column] if c.F != nil && c.F.Ref != "" && c.F.T == STCellFormulaTypeShared && c.F.Si != nil && *c.F.Si == si { col, row, _ := CellNameToCoordinates(cell) sharedCol, sharedRow, _ := CellNameToCoordinates(c.R)