uniqueschars: use map cap based on input
This commit is contained in:
@ -1,9 +1,12 @@
|
|||||||
package uniqueschars
|
package uniqueschars
|
||||||
|
|
||||||
import "unicode"
|
import (
|
||||||
|
"unicode"
|
||||||
|
"unicode/utf8"
|
||||||
|
)
|
||||||
|
|
||||||
func Unique(s string) bool {
|
func Unique(s string) bool {
|
||||||
m := make(map[rune]struct{}, 50)
|
m := make(map[rune]struct{}, utf8.RuneCountInString(s)/2)
|
||||||
|
|
||||||
for _, c := range s {
|
for _, c := range s {
|
||||||
c := unicode.ToLower(c)
|
c := unicode.ToLower(c)
|
||||||
|
Reference in New Issue
Block a user