From 05d88648293d3ef1a323a27616a53a0c5f69240c Mon Sep 17 00:00:00 2001 From: Lars Karlslund Date: Wed, 7 Sep 2022 18:10:55 +0200 Subject: [PATCH] Let's not allocate a new Error every time --- modules/engine/object.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/engine/object.go b/modules/engine/object.go index 7812251..c2a1848 100644 --- a/modules/engine/object.go +++ b/modules/engine/object.go @@ -1033,18 +1033,22 @@ func (o *Object) ValueMap() map[string][]string { return result } +var ErrNoSecurityDescriptor = errors.New("no security desciptor") + // Return parsed security descriptor func (o *Object) SecurityDescriptor() (*SecurityDescriptor, error) { if o.sdcache == nil { - return nil, errors.New("no security desciptor") + return nil, ErrNoSecurityDescriptor } return o.sdcache, nil } +var ErrEmptySecurityDescriptorAttribute = errors.New("empty nTSecurityDescriptor attribute!?") + // Parse and cache security descriptor func (o *Object) cacheSecurityDescriptor(rawsd []byte) error { if len(rawsd) == 0 { - return errors.New("empty nTSecurityDescriptor attribute!?") + return ErrEmptySecurityDescriptorAttribute } securitydescriptorcachemutex.RLock()