Skip to content

Commit 8cfd121

Browse files
common: improve pretty duration regex (ethereum#25073)
* common: improve pretty duration regex * common: improve pretty duration regex
1 parent 6ad620d commit 8cfd121

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

common/format.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ import (
2727
// the unnecessary precision off from the formatted textual representation.
2828
type PrettyDuration time.Duration
2929

30-
var prettyDurationRe = regexp.MustCompile(`\.[0-9]+`)
30+
var prettyDurationRe = regexp.MustCompile(`\.[0-9]{4,}`)
3131

3232
// String implements the Stringer interface, allowing pretty printing of duration
3333
// values rounded to three decimals.
3434
func (d PrettyDuration) String() string {
35-
label := fmt.Sprintf("%v", time.Duration(d))
35+
label := time.Duration(d).String()
3636
if match := prettyDurationRe.FindString(label); len(match) > 4 {
3737
label = strings.Replace(label, match, match[:4], 1)
3838
}

0 commit comments

Comments
 (0)