Optimize getSharedFormula to avoid runtime.duffcopy (#1837)

This commit is contained in:
Paolo Barbolini 2024-03-03 02:39:50 +01:00 committed by GitHub
parent 9d4c2e60f6
commit 963a058535
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -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 // Note that this function not validate ref tag to check the cell whether in
// allow range reference, and always return origin shared formula. // allow range reference, and always return origin shared formula.
func getSharedFormula(ws *xlsxWorksheet, si int, cell string) string { func getSharedFormula(ws *xlsxWorksheet, si int, cell string) string {
for _, r := range ws.SheetData.Row { for row := 0; row < len(ws.SheetData.Row); row++ {
for _, c := range r.C { 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 { if c.F != nil && c.F.Ref != "" && c.F.T == STCellFormulaTypeShared && c.F.Si != nil && *c.F.Si == si {
col, row, _ := CellNameToCoordinates(cell) col, row, _ := CellNameToCoordinates(cell)
sharedCol, sharedRow, _ := CellNameToCoordinates(c.R) sharedCol, sharedRow, _ := CellNameToCoordinates(c.R)