From dd60972c9382f0adcf7c5ad71f0472691c93d918 Mon Sep 17 00:00:00 2001 From: Kubo Ryosuke Date: Tue, 16 Jan 2024 12:08:50 +0900 Subject: [PATCH] Reduce buildFields function call --- mp4.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mp4.go b/mp4.go index c8c55f7..2fab24d 100644 --- a/mp4.go +++ b/mp4.go @@ -100,6 +100,8 @@ func AddAnyTypeBoxDefEx(payload IAnyType, boxType BoxType, isTarget func(Context }) } +var itemBoxFields = buildFields(&Item{}) + func (boxType BoxType) getBoxDef(ctx Context) *boxDef { boxDefs := boxMap[boxType] for i := len(boxDefs) - 1; i >= 0; i-- { @@ -111,11 +113,10 @@ func (boxType BoxType) getBoxDef(ctx Context) *boxDef { if ctx.UnderIlst { typeID := int(binary.BigEndian.Uint32(boxType[:])) if typeID >= 1 && typeID <= ctx.QuickTimeKeysMetaEntryCount { - payload := &Item{} return &boxDef{ - dataType: reflect.TypeOf(payload).Elem(), + dataType: reflect.TypeOf(Item{}), isTarget: isIlstMetaContainer, - fields: buildFields(payload), + fields: itemBoxFields, } } }