From c168233e70db8f220bd07d9d6d277ae9e2a4a73f Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 27 May 2020 00:02:29 +0800 Subject: speedup get cell value from shared string table --- cell.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'cell.go') diff --git a/cell.go b/cell.go index e64ef26..6981cce 100644 --- a/cell.go +++ b/cell.go @@ -299,14 +299,13 @@ func (f *File) setCellString(value string) (t string, v string, ns xml.Attr) { // setSharedString provides a function to add string to the share string table. func (f *File) setSharedString(val string) int { sst := f.sharedStringsReader() - for i, si := range sst.SI { - if si.T == val { - return i - } + if i, ok := f.sharedStringsMap[val]; ok { + return i } sst.Count++ sst.UniqueCount++ sst.SI = append(sst.SI, xlsxSI{T: val}) + f.sharedStringsMap[val] = sst.UniqueCount - 1 return sst.UniqueCount - 1 } -- cgit v1.2.1