summaryrefslogtreecommitdiff
path: root/cell.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2020-05-27 00:02:29 +0800
committerxuri <xuri.me@gmail.com>2020-05-27 00:02:29 +0800
commitc168233e70db8f220bd07d9d6d277ae9e2a4a73f (patch)
treeb5bba69c6bc4fc0b2a1429d3893d7a84eff6360b /cell.go
parent5c99300ee44de15e92bd8c5a92f2183c804d1379 (diff)
speedup get cell value from shared string table
Diffstat (limited to 'cell.go')
-rw-r--r--cell.go7
1 files changed, 3 insertions, 4 deletions
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
}