From f6bc5ac53834edeb111e3f91ac4bb7e9794c167e Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 21 Aug 2025 19:20:09 +0800 Subject: [PATCH] cl/instr:regexp compile one time --- cl/instr.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cl/instr.go b/cl/instr.go index 82c3b620..42c8ab9e 100644 --- a/cl/instr.go +++ b/cl/instr.go @@ -29,6 +29,8 @@ import ( llssa "github.com/goplus/llgo/ssa" ) +var asmRegisterRegex = regexp.MustCompile(`\{[a-zA-Z]+\}`) + // ----------------------------------------------------------------------------- func constStr(v ssa.Value) (ret string, ok bool) { @@ -124,7 +126,7 @@ func (p *context) asmFull(b llssa.Builder, args []ssa.Value) (ret llssa.Expr) { hasOutput = true } - finalAsm = regexp.MustCompile(`\{[a-zA-Z]+\}`).ReplaceAllStringFunc(finalAsm, func(s string) string { + finalAsm = asmRegisterRegex.ReplaceAllStringFunc(finalAsm, func(s string) string { // TODO: skip strings like {r4} etc. that look like ARM push/pop // instructions. name := s[1 : len(s)-1]