From d96440edc480976e3ec48958c68e67f7a506ad32 Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 15 May 2018 21:00:56 +0800 Subject: [PATCH] - 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 --- .github/ISSUE_TEMPLATE.md | 6 ++---- CONTRIBUTING.md | 19 +++++++++---------- excelize_test.go | 3 +++ sheet.go | 20 +++++++++++++++----- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index d93dd0d8a9..5d7e931c4a 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.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 expected:** - **Output of `go version`:** -``` +```text (paste your output here) ``` **Excelize version or commit ID:** -``` +```text (paste here) ``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 27705c8145..5239a94704 100644 --- a/CONTRIBUTING.md +++ b/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 ruling it out in the future. - ## Reporting other issues 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 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 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: -- 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. -- 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 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 the below (from [developercertificate.org](http://developercertificate.org/)): -``` +```text Developer Certificate of Origin 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 commit automatically with `git commit -s`. -### How can I become a maintainer? +### How can I become a maintainer 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. It's easy to appreciate a really cool and technically advanced feature. It's harder diff --git a/excelize_test.go b/excelize_test.go index df1b35a13c..f1f23b47c7 100644 --- a/excelize_test.go +++ b/excelize_test.go @@ -85,6 +85,9 @@ func TestOpenFile(t *testing.T) { xlsx.SetCellValue("Sheet2", "F17", complex64(5+10i)) t.Log(letterOnlyMapF('x')) t.Log(deepCopy(nil, nil)) + shiftJulianToNoon(1, -0.6) + timeFromExcelTime(61, true) + timeFromExcelTime(62, true) // Test boolean write booltest := []struct { value bool diff --git a/sheet.go b/sheet.go index 10a0fdb679..cb3bba202e 100644 --- a/sheet.go +++ b/sheet.go @@ -94,13 +94,15 @@ func (f *File) worksheetWriter() { // trimCell provides function to trim blank cells which created by completeCol. func trimCell(column []xlsxC) []xlsxC { - col := []xlsxC{} + col := make([]xlsxC, len(column)) + i := 0 for _, c := range column { 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. @@ -641,8 +643,16 @@ func (f *File) GetSheetVisible(name string) bool { // trimSheetName provides function to trim invaild characters by given worksheet // name. 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 { name = string([]rune(name)[0:31]) }