From 024ba8b2f0fcc854c7a42cb8e84e05e9280997be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lelzin=20=CE=BB?= Date: Wed, 25 Sep 2024 12:14:24 -0300 Subject: [PATCH] refactor: store padding regex in a package-level variable --- internal/dbus.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/dbus.go b/internal/dbus.go index abd3b52..f3a1f52 100644 --- a/internal/dbus.go +++ b/internal/dbus.go @@ -65,11 +65,12 @@ const DBUS_XML = ` ` var ( - conn *dbus.Conn - hyprsock HyprConn - ongoing_notifications map[uint32]chan uint32 = make(map[uint32]chan uint32) - current_id uint32 = 0 - sound bool + conn *dbus.Conn + hyprsock HyprConn + ongoing_notifications map[uint32]chan uint32 = make(map[uint32]chan uint32) + current_id uint32 = 0 + sound bool + notification_padding_regexp *regexp.Regexp = regexp.MustCompile("^\\s*|(\n)\\s*(.)") ) type DBusNotify string @@ -117,8 +118,7 @@ func (n DBusNotify) Notify( } // Using RegExp to add padding for all lines - nf.message = regexp. - MustCompile("^\\s*|(\n)\\s*(.)"). + nf.message = notification_padding_regexp. ReplaceAllString( strings.TrimLeft(nf.message, "\n"), "$1\u205F $2",