From eef0d2f00bea02da2416ef79b66d38b4921a735b Mon Sep 17 00:00:00 2001 From: Kennedy Bushnell Date: Tue, 21 Apr 2026 22:11:12 -0700 Subject: [PATCH] perf: avoid LoadLocation syscall for each TibiaDataDatetime call --- src/TibiaDataUtils.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TibiaDataUtils.go b/src/TibiaDataUtils.go index 98ac64d7..79d35c26 100644 --- a/src/TibiaDataUtils.go +++ b/src/TibiaDataUtils.go @@ -16,6 +16,9 @@ import ( "golang.org/x/text/unicode/norm" ) +// berlinLocation is cached to avoid repeated time.LoadLocation calls per request. +var berlinLocation, _ = time.LoadLocation("Europe/Berlin") + // TibiaDataDatetime func func TibiaDataDatetime(date string) string { //TODO: Normalization needs to happen above this layer @@ -31,14 +34,11 @@ func TibiaDataDatetime(date string) string { // The string that should be returned is the current timestamp returnDate = time.Now() } else { - // timezone use in html: CET/CEST - loc, _ := time.LoadLocation("Europe/Berlin") - // format used in datetime on html: Jan 02 2007, 19:20:30 CET formatting := "Jan 02 2006, 15:04:05 MST" // parsing html in time with location set in loc - returnDate, err = time.ParseInLocation(formatting, date, loc) + returnDate, err = time.ParseInLocation(formatting, date, berlinLocation) // parsing html in tiem without loc //returnDate, err = time.Parse("Jan 02 2006, 15:04:05 MST", date)