Skip to content

Commit 2bee013

Browse files
sabandifelixge
authored andcommitted
Replace fmt.Sscanf with strconv.Atoi for faster int conversion
1 parent 5aa20cb commit 2bee013

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

handler.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package fgprof
33
import (
44
"fmt"
55
"net/http"
6+
"strconv"
67
"time"
78
)
89

@@ -15,7 +16,7 @@ func Handler() http.Handler {
1516
var seconds int
1617
if s := r.URL.Query().Get("seconds"); s == "" {
1718
seconds = 30
18-
} else if _, err := fmt.Sscanf(s, "%d", &seconds); err != nil || seconds <= 0 {
19+
} else if seconds, err := strconv.Atoi(s); err != nil || seconds <= 0 {
1920
w.WriteHeader(http.StatusBadRequest)
2021
fmt.Fprintf(w, "bad seconds: %d: %s\n", seconds, err)
2122
}

0 commit comments

Comments
 (0)