From d16d05ecad8d146ef127c975e2e3e167b6e38ad6 Mon Sep 17 00:00:00 2001 From: bogem Date: Sat, 10 Sep 2016 12:08:47 +0500 Subject: Use strconv instead of fmt in values' String funcs The existing implementation of flag values with fmt package uses more memory and works slower than the implementation with strconv package. --- count.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'count.go') diff --git a/count.go b/count.go index 7b1f142..d22be41 100644 --- a/count.go +++ b/count.go @@ -1,9 +1,6 @@ package pflag -import ( - "fmt" - "strconv" -) +import "strconv" // -- count Value type countValue int @@ -28,7 +25,7 @@ func (i *countValue) Type() string { return "count" } -func (i *countValue) String() string { return fmt.Sprintf("%v", *i) } +func (i *countValue) String() string { return strconv.Itoa(int(*i)) } func countConv(sval string) (interface{}, error) { i, err := strconv.Atoi(sval) -- cgit v1.2.3