From 6ff95ac7074ec7d04dbdcd9c52c651a11b41e1de Mon Sep 17 00:00:00 2001 From: Zxilly Date: Fri, 19 Jul 2024 18:41:46 +0800 Subject: [PATCH] pref: reduce allocation Signed-off-by: Zxilly --- internal/dwarf/dwarf.go | 20 ++++++++++---------- internal/knowninfo/disasm.go | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/dwarf/dwarf.go b/internal/dwarf/dwarf.go index 54b3eb0158..ab8da82585 100644 --- a/internal/dwarf/dwarf.go +++ b/internal/dwarf/dwarf.go @@ -84,6 +84,16 @@ func SizeForDWARFVar( return nil, uint64(typ.Size()), nil } +var boolIgnores = [...]dwarf.Attr{ + dwarf.AttrCallAllCalls, + dwarf.AttrCallAllTailCalls, +} + +var ignores = [...]dwarf.Attr{ + dwarf.AttrAbstractOrigin, + dwarf.AttrSpecification, +} + func EntryShouldIgnore(entry *dwarf.Entry) bool { declaration := entry.Val(dwarf.AttrDeclaration) if declaration != nil { @@ -99,11 +109,6 @@ func EntryShouldIgnore(entry *dwarf.Entry) bool { } } - boolIgnores := []dwarf.Attr{ - dwarf.AttrCallAllCalls, - dwarf.AttrCallAllTailCalls, - } - for _, ignore := range boolIgnores { valAny := entry.Val(ignore) if valAny != nil { @@ -118,11 +123,6 @@ func EntryShouldIgnore(entry *dwarf.Entry) bool { } } - ignores := []dwarf.Attr{ - dwarf.AttrAbstractOrigin, - dwarf.AttrSpecification, - } - for _, ignore := range ignores { if entry.Val(ignore) != nil { return true diff --git a/internal/knowninfo/disasm.go b/internal/knowninfo/disasm.go index 160934c441..6021dee2e7 100644 --- a/internal/knowninfo/disasm.go +++ b/internal/knowninfo/disasm.go @@ -57,7 +57,7 @@ func (k *KnownInfo) Disasm() error { ) for fn := range k.Deps.Functions { - if err := sem.Acquire(resultProcess, 1); err != nil { + if err = sem.Acquire(resultProcess, 1); err != nil { slog.Error(fmt.Sprintf("Failed to acquire semaphore: %v", err)) break }