summaryrefslogtreecommitdiff
path: root/sheet.go
diff options
context:
space:
mode:
authorSean Liang <sunlxy@yahoo.com>2021-11-03 15:13:46 +0800
committerGitHub <noreply@github.com>2021-11-03 15:13:46 +0800
commit32548a6cac35caced7d016074c2de4219ad5de01 (patch)
tree4daf3c4282026d845a26f7be39dcdfeb1b3966ee /sheet.go
parent08ad10f68e0c603bac1499a0d7b93b251123a54b (diff)
return immediately when matched for efficiency (#1049)
Diffstat (limited to 'sheet.go')
-rw-r--r--sheet.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/sheet.go b/sheet.go
index e5ea1bd..dc93513 100644
--- a/sheet.go
+++ b/sheet.go
@@ -325,6 +325,7 @@ func (f *File) GetActiveSheetIndex() (index int) {
for idx, sheet := range wb.Sheets.Sheet {
if sheet.SheetID == sheetID {
index = idx
+ return
}
}
}
@@ -377,6 +378,7 @@ func (f *File) GetSheetName(index int) (name string) {
for idx, sheet := range f.GetSheetList() {
if idx == index {
name = sheet
+ return
}
}
return
@@ -386,13 +388,12 @@ func (f *File) GetSheetName(index int) (name string) {
// given sheet name. If given worksheet name is invalid, will return an
// integer type value -1.
func (f *File) getSheetID(name string) int {
- var ID = -1
for sheetID, sheet := range f.GetSheetMap() {
if sheet == trimSheetName(name) {
- ID = sheetID
+ return sheetID
}
}
- return ID
+ return -1
}
// GetSheetIndex provides a function to get a sheet index of the workbook by
@@ -400,13 +401,12 @@ func (f *File) getSheetID(name string) int {
// sheet name is invalid or sheet doesn't exist, it will return an integer
// type value -1.
func (f *File) GetSheetIndex(name string) int {
- var idx = -1
for index, sheet := range f.GetSheetList() {
if strings.EqualFold(sheet, trimSheetName(name)) {
- idx = index
+ return index
}
}
- return idx
+ return -1
}
// GetSheetMap provides a function to get worksheets, chart sheets, dialog