From a6f536861cacf3513f1770d8eb1051d4db952fb8 Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 29 Dec 2021 19:11:59 +0200 Subject: [PATCH] embed resources to avoid pointer indirection --- scope.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/scope.go b/scope.go index 08b03a1..216e5ca 100644 --- a/scope.go +++ b/scope.go @@ -32,7 +32,7 @@ type ResourceScope struct { done bool refCnt int - rc *resources + rc resources owner *ResourceScope // set in transaction scopes, which define trees constraints []*ResourceScope // set in DAG scopes, it's the linearized parent set } @@ -40,25 +40,19 @@ type ResourceScope struct { var _ network.ResourceScope = (*ResourceScope)(nil) var _ network.TransactionalScope = (*ResourceScope)(nil) -func newResources(limit Limit) *resources { - return &resources{ - limit: limit, - } -} - func NewResourceScope(limit Limit, constraints []*ResourceScope) *ResourceScope { for _, cst := range constraints { cst.IncRef() } return &ResourceScope{ - rc: newResources(limit), + rc: resources{limit: limit}, constraints: constraints, } } func NewTxnResourceScope(owner *ResourceScope) *ResourceScope { return &ResourceScope{ - rc: newResources(owner.rc.limit), + rc: resources{limit: owner.rc.limit}, owner: owner, } }