Skip to content

Commit 963a058

Browse files
Optimize getSharedFormula to avoid runtime.duffcopy (#1837)
1 parent 9d4c2e6 commit 963a058

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cell.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,8 +1655,10 @@ func parseSharedFormula(dCol, dRow int, orig []byte) (res string, start int) {
16551655
// Note that this function not validate ref tag to check the cell whether in
16561656
// allow range reference, and always return origin shared formula.
16571657
func getSharedFormula(ws *xlsxWorksheet, si int, cell string) string {
1658-
for _, r := range ws.SheetData.Row {
1659-
for _, c := range r.C {
1658+
for row := 0; row < len(ws.SheetData.Row); row++ {
1659+
r := &ws.SheetData.Row[row]
1660+
for column := 0; column < len(r.C); column++ {
1661+
c := &r.C[column]
16601662
if c.F != nil && c.F.Ref != "" && c.F.T == STCellFormulaTypeShared && c.F.Si != nil && *c.F.Si == si {
16611663
col, row, _ := CellNameToCoordinates(cell)
16621664
sharedCol, sharedRow, _ := CellNameToCoordinates(c.R)

0 commit comments

Comments
 (0)