-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
492 changed files
with
370,753 additions
and
22,294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
goos: linux | ||
goarch: amd64 | ||
pkg: acronym | ||
cpu: Intel(R) Core(TM) i7-7Y75 CPU @ 1.30GHz | ||
BenchmarkAcronym-4 5791 305661 ns/op 30838 B/op 426 allocs/op | ||
cpu: 12th Gen Intel(R) Core(TM) i5-1240P | ||
BenchmarkAcronym | ||
BenchmarkAcronym-8 20481 57491 ns/op 31138 B/op 426 allocs/op | ||
PASS | ||
ok acronym 1.839s | ||
ok acronym 1.718s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
11 func Abbreviate(s string) string { | ||
12 var a string | ||
13 | ||
14 // Since we can't use cases or language, we have to do some pre-processing. | ||
15 reStr := `(["'_;:.]|[[:digit:]])` | ||
16 | ||
17 re, e := regexp.Compile(reStr) | ||
18 if e != nil { | ||
19 // the raw re string is static but you can still make mistakes, better | ||
20 // to panic during tests than quietly "working" incorrectly. | ||
21 MISS panic(e) | ||
22 } | ||
23 | ||
24 a = re.ReplaceAllString(s, "") | ||
25 | ||
26 // Get the title converted string. | ||
27 // Using deprecated function, the test harness doesn't run `go mod tidy` or | ||
28 // it also lacks Internet access. | ||
29 a = strings.ToLower(a) | ||
30 a = strings.Title(a) | ||
31 | ||
32 // Thought about looping through the string to find uppercase letters, | ||
33 // decided on just using regexp to remove everything else instead. | ||
34 // I've tried using the strings IsSomething functions befoer and they're a mess. | ||
35 reStr = `([[:lower:]]|[[:blank:]]|[[:punct:]])` | ||
36 | ||
37 re, e = regexp.Compile(reStr) | ||
38 if e != nil { | ||
39 // the raw re string is static but you can still make mistakes, better | ||
40 // to panic during tests than quietly "working" incorrectly. | ||
41 MISS panic(e) | ||
42 } | ||
43 | ||
44 a = re.ReplaceAllString(a, "") | ||
45 | ||
46 return a | ||
47 } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
mode: count | ||
acronym/acronym.go:11.34,18.14 4 10 | ||
acronym/acronym.go:24.2,38.14 6 10 | ||
acronym/acronym.go:44.2,46.10 2 10 | ||
acronym/acronym.go:18.14,21.11 1 0 | ||
acronym/acronym.go:24.2,38.14 6 10 | ||
acronym/acronym.go:38.14,41.11 1 0 | ||
acronym/acronym.go:44.2,46.10 2 10 |
Oops, something went wrong.