Skip to content

Commit

Permalink
Let's not allocate a new Error every time
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Sep 7, 2022
1 parent da9dd97 commit 05d8864
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions modules/engine/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 05d8864

Please sign in to comment.