From ad4d977c291e5fe616d330d1618aed9117259b1b Mon Sep 17 00:00:00 2001 From: n3wbie Date: Thu, 26 Dec 2024 21:21:55 +0900 Subject: [PATCH] fix: --- _deploy/r/gnoswap/common/grc20reg_helper.gno | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/_deploy/r/gnoswap/common/grc20reg_helper.gno b/_deploy/r/gnoswap/common/grc20reg_helper.gno index a959e94d..5f521a85 100644 --- a/_deploy/r/gnoswap/common/grc20reg_helper.gno +++ b/_deploy/r/gnoswap/common/grc20reg_helper.gno @@ -10,6 +10,10 @@ import ( "gno.land/r/demo/grc20reg" ) +var ( + re = regexp.MustCompile(`\[gno\.land/r/[^\]]+\]`) +) + // GetToken returns a grc20.Token instance // if token is not registered, it will panic // token instance supports following methods: @@ -70,10 +74,9 @@ func ListRegisteredTokens() []string { } func extractTokenPathsFromRender(render string) []string { - re := regexp.MustCompile(`\[gno\.land/r/[^\]]+\]`) matches := re.FindAllString(render, -1) - tokenPaths := []string{} + tokenPaths := make([]string, 0, len(matches)) for _, match := range matches { tokenPath := strings.Trim(match, "[]") // Remove the brackets tokenPaths = append(tokenPaths, tokenPath)