Browse Source

- Performance optimization 20% faster, 14% memory savings on set cell values;
- Using the canonical syntax in issue template and contributing guide;
- go test has been updated

xuri 7 years ago
parent
commit
d96440edc4
4 changed files with 29 additions and 19 deletions
  1. 2 4
      .github/ISSUE_TEMPLATE.md
  2. 9 10
      CONTRIBUTING.md
  3. 3 0
      excelize_test.go
  4. 15 5
      sheet.go

+ 2 - 4
.github/ISSUE_TEMPLATE.md

@@ -21,19 +21,17 @@ Briefly describe the problem you are having in a few paragraphs.
 
 
 **Describe the results you received:**
 **Describe the results you received:**
 
 
-
 **Describe the results you expected:**
 **Describe the results you expected:**
 
 
-
 **Output of `go version`:**
 **Output of `go version`:**
 
 
-```
+```text
 (paste your output here)
 (paste your output here)
 ```
 ```
 
 
 **Excelize version or commit ID:**
 **Excelize version or commit ID:**
 
 
-```
+```text
 (paste here)
 (paste here)
 ```
 ```
 
 

+ 9 - 10
CONTRIBUTING.md

@@ -25,7 +25,6 @@ Security reports are greatly appreciated and we will publicly thank you for it.
 We currently do not offer a paid security bounty program, but are not
 We currently do not offer a paid security bounty program, but are not
 ruling it out in the future.
 ruling it out in the future.
 
 
-
 ## Reporting other issues
 ## Reporting other issues
 
 
 A great way to contribute to the project is to send a detailed report when you
 A great way to contribute to the project is to send a detailed report when you
@@ -44,7 +43,7 @@ When reporting issues, always include the output of `go env`.
 
 
 Also include the steps required to reproduce the problem if possible and
 Also include the steps required to reproduce the problem if possible and
 applicable. This information will help us review and fix your issue faster.
 applicable. This information will help us review and fix your issue faster.
-When sending lengthy log-files, consider posting them as a gist (https://gist.github.com).
+When sending lengthy log-files, consider posting them as a gist [https://gist.github.com](https://gist.github.com).
 Don't forget to remove sensitive data from your logfiles before posting (you can
 Don't forget to remove sensitive data from your logfiles before posting (you can
 replace those parts with "REDACTED").
 replace those parts with "REDACTED").
 
 
@@ -77,9 +76,9 @@ However, there might be a way to implement that feature *on top of* excelize.
 
 
 Fork the repository and make changes on your fork in a feature branch:
 Fork the repository and make changes on your fork in a feature branch:
 
 
-- If it's a bug fix branch, name it XXXX-something where XXXX is the number of
+* If it's a bug fix branch, name it XXXX-something where XXXX is the number of
     the issue.
     the issue.
-- If it's a feature branch, create an enhancement issue to announce
+* If it's a feature branch, create an enhancement issue to announce
     your intentions, and name it XXXX-something where XXXX is the number of the
     your intentions, and name it XXXX-something where XXXX is the number of the
     issue.
     issue.
 
 
@@ -194,7 +193,7 @@ signature certifies that you wrote the patch or otherwise have the right to pass
 it on as an open-source patch. The rules are pretty simple: if you can certify
 it on as an open-source patch. The rules are pretty simple: if you can certify
 the below (from [developercertificate.org](http://developercertificate.org/)):
 the below (from [developercertificate.org](http://developercertificate.org/)):
 
 
-```
+```text
 Developer Certificate of Origin
 Developer Certificate of Origin
 Version 1.1
 Version 1.1
 
 
@@ -242,14 +241,14 @@ Use your real name (sorry, no pseudonyms or anonymous contributions.)
 If you set your `user.name` and `user.email` git configs, you can sign your
 If you set your `user.name` and `user.email` git configs, you can sign your
 commit automatically with `git commit -s`.
 commit automatically with `git commit -s`.
 
 
-### How can I become a maintainer?
+### How can I become a maintainer
 
 
 First, all maintainers have 3 things
 First, all maintainers have 3 things
 
 
-- They share responsibility in the project's success.
-- They have made a long-term, recurring time investment to improve the project.
-- They spend that time doing whatever needs to be done, not necessarily what
-is the most interesting or fun.
+* They share responsibility in the project's success.
+* They have made a long-term, recurring time investment to improve the project.
+* They spend that time doing whatever needs to be done, not necessarily what
+ is the most interesting or fun.
 
 
 Maintainers are often under-appreciated, because their work is harder to appreciate.
 Maintainers are often under-appreciated, because their work is harder to appreciate.
 It's easy to appreciate a really cool and technically advanced feature. It's harder
 It's easy to appreciate a really cool and technically advanced feature. It's harder

+ 3 - 0
excelize_test.go

@@ -85,6 +85,9 @@ func TestOpenFile(t *testing.T) {
 	xlsx.SetCellValue("Sheet2", "F17", complex64(5+10i))
 	xlsx.SetCellValue("Sheet2", "F17", complex64(5+10i))
 	t.Log(letterOnlyMapF('x'))
 	t.Log(letterOnlyMapF('x'))
 	t.Log(deepCopy(nil, nil))
 	t.Log(deepCopy(nil, nil))
+	shiftJulianToNoon(1, -0.6)
+	timeFromExcelTime(61, true)
+	timeFromExcelTime(62, true)
 	// Test boolean write
 	// Test boolean write
 	booltest := []struct {
 	booltest := []struct {
 		value    bool
 		value    bool

+ 15 - 5
sheet.go

@@ -94,13 +94,15 @@ func (f *File) worksheetWriter() {
 
 
 // trimCell provides function to trim blank cells which created by completeCol.
 // trimCell provides function to trim blank cells which created by completeCol.
 func trimCell(column []xlsxC) []xlsxC {
 func trimCell(column []xlsxC) []xlsxC {
-	col := []xlsxC{}
+	col := make([]xlsxC, len(column))
+	i := 0
 	for _, c := range column {
 	for _, c := range column {
 		if c.S != 0 || c.V != "" || c.F != nil || c.T != "" {
 		if c.S != 0 || c.V != "" || c.F != nil || c.T != "" {
-			col = append(col, c)
+			col[i] = c
+			i++
 		}
 		}
 	}
 	}
-	return col
+	return col[0:i]
 }
 }
 
 
 // Read and update property of contents type of XLSX.
 // Read and update property of contents type of XLSX.
@@ -641,8 +643,16 @@ func (f *File) GetSheetVisible(name string) bool {
 // trimSheetName provides function to trim invaild characters by given worksheet
 // trimSheetName provides function to trim invaild characters by given worksheet
 // name.
 // name.
 func trimSheetName(name string) string {
 func trimSheetName(name string) string {
-	r := strings.NewReplacer(":", "", "\\", "", "/", "", "?", "", "*", "", "[", "", "]", "")
-	name = r.Replace(name)
+	r := []rune{}
+	for _, v := range []rune(name) {
+		switch v {
+		case 58, 92, 47, 63, 42, 91, 93: // replace :\/?*[]
+			continue
+		default:
+			r = append(r, v)
+		}
+	}
+	name = string(r)
 	if utf8.RuneCountInString(name) > 31 {
 	if utf8.RuneCountInString(name) > 31 {
 		name = string([]rune(name)[0:31])
 		name = string([]rune(name)[0:31])
 	}
 	}