Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ASCIISet #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions dxcc/gen/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"sort"
"strconv"
"strings"

"github.com/elliotwutingfeng/asciiset"
)

// reads cty.csv from http://www.country-files.com/
Expand Down Expand Up @@ -97,20 +99,21 @@ func splitPrefixes(pfx string) string {

func prefixRegexp(pfx string) string {

initialChars := map[byte]struct{}{}
initialChars, _ := asciiset.MakeASCIISet("")
pfx = strings.Replace(pfx, ";", "", -1)
for _, p := range strings.Split(pfx, " ") {
switch p[0] {
case '=':
initialChars[p[1]] = struct{}{}
initialChars.Add(p[1])
default:
initialChars[p[0]] = struct{}{}
initialChars.Add(p[0])
}
}
var sorted []byte
for c := range initialChars {
initialChars.Visit(func(c byte) bool {
sorted = append(sorted, c)
}
return false
})
sort.Slice(sorted, func(i, j int) bool {
return sorted[i] < sorted[j]
})
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca
github.com/dh1tw/goHamlib v0.0.0-20210309231416-3752aec70bb9
github.com/dustin/go-humanize v1.0.0
github.com/elliotwutingfeng/asciiset v0.0.0-20230905005145-03469a5e6723
github.com/go-git/go-git/v5 v5.0.0
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ github.com/dh1tw/goHamlib v0.0.0-20210309231416-3752aec70bb9 h1:Nesja9SyFN+AbgzE
github.com/dh1tw/goHamlib v0.0.0-20210309231416-3752aec70bb9/go.mod h1:jK1ydgaErxhywGam57gVArV1Z20/f/8zUfdSqTmZdTk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/elliotwutingfeng/asciiset v0.0.0-20230905005145-03469a5e6723 h1:5NV4VYUVfpKnS0rNIvz6KUbpp0DSupqBl9Ebdu6v2II=
github.com/elliotwutingfeng/asciiset v0.0.0-20230905005145-03469a5e6723/go.mod h1:GLo/8fDswSAniFG+BFIaiSPcK610jyzgEhWYPQwuQdw=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
Expand Down