From 1321762859d6d5dbd1b75c8e5b6c9f63be315c1d Mon Sep 17 00:00:00 2001 From: Brat-vseznamus Date: Tue, 16 Jul 2024 13:46:55 +0300 Subject: [PATCH] update code in "meta" --- internal/tlcodegen/qt_meta.qtpl | 31 +++++-------------- internal/tlcodegen/qt_meta.qtpl.go | 31 +++++-------------- .../tlcodegen/test/gen/cases/meta/meta.go | 30 +++++------------- .../test/gen/goldmaster/meta/meta.go | 30 +++++------------- .../test/gen/goldmaster_nosplit/meta/meta.go | 30 +++++------------- 5 files changed, 35 insertions(+), 117 deletions(-) diff --git a/internal/tlcodegen/qt_meta.qtpl b/internal/tlcodegen/qt_meta.qtpl index 6a11600c..1d6b8ac2 100644 --- a/internal/tlcodegen/qt_meta.qtpl +++ b/internal/tlcodegen/qt_meta.qtpl @@ -95,14 +95,14 @@ func CreateObjectFromName(name string) Object { } func CreateFunctionBytes(tag uint32) Function { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil } func CreateObjectBytes(tag uint32) Object { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -110,7 +110,7 @@ func CreateObjectBytes(tag uint32) Object { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateFunctionFromNameBytes(name string) Function { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil @@ -118,7 +118,7 @@ func CreateFunctionFromNameBytes(name string) Function { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateObjectFromNameBytes(name string) Object { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -235,23 +235,10 @@ func FactoryItemByTLName(name string) *TLItem { return itemsByName[name] } -func FactoryItemByTLTagBytes(tag uint32) *TLItem { - return itemsBytesByTag[tag] -} - -func FactoryItemByTLNameBytes(name string) *TLItem { - return itemsBytesByName[name] -} - - var itemsByTag = map[uint32]*TLItem {} var itemsByName = map[string]*TLItem {} -var itemsBytesByTag = map[uint32]*TLItem {} - -var itemsBytesByName = map[string]*TLItem {} - func SetGlobalFactoryCreateForFunction(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { item := itemsByTag[itemTag] if item == nil { @@ -279,7 +266,7 @@ func SetGlobalFactoryCreateForEnumElement(itemTag uint32) { } func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find function tag #%08x to set", itemTag)) } @@ -289,7 +276,7 @@ func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() } func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Object) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find item tag #%08x to set", itemTag)) } @@ -297,7 +284,7 @@ func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Ob } func SetGlobalFactoryCreateForEnumElementBytes(itemTag uint32) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find enum tag #%08x to set", itemTag)) } @@ -325,10 +312,6 @@ func fillObject(n1 string, n2 string, item *TLItem) { itemsByName[item.tlName] = item itemsByName[n1] = item itemsByName[n2] = item - itemsBytesByTag[item.tag] = item - itemsBytesByName[item.tlName] = item - itemsBytesByName[n1] = item - itemsBytesByName[n2] = item item.createObject = pleaseImportFactoryObject item.createObjectBytes = pleaseImportFactoryBytesObject // code below is as fast, but allocates some extra strings which are already in binary const segment due to JSON code diff --git a/internal/tlcodegen/qt_meta.qtpl.go b/internal/tlcodegen/qt_meta.qtpl.go index 01ea8b0f..aa3b6025 100644 --- a/internal/tlcodegen/qt_meta.qtpl.go +++ b/internal/tlcodegen/qt_meta.qtpl.go @@ -124,14 +124,14 @@ func CreateObjectFromName(name string) Object { } func CreateFunctionBytes(tag uint32) Function { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil } func CreateObjectBytes(tag uint32) Object { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -139,7 +139,7 @@ func CreateObjectBytes(tag uint32) Object { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateFunctionFromNameBytes(name string) Function { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil @@ -147,7 +147,7 @@ func CreateFunctionFromNameBytes(name string) Function { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateObjectFromNameBytes(name string) Object { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -275,23 +275,10 @@ func FactoryItemByTLName(name string) *TLItem { return itemsByName[name] } -func FactoryItemByTLTagBytes(tag uint32) *TLItem { - return itemsBytesByTag[tag] -} - -func FactoryItemByTLNameBytes(name string) *TLItem { - return itemsBytesByName[name] -} - - var itemsByTag = map[uint32]*TLItem {} var itemsByName = map[string]*TLItem {} -var itemsBytesByTag = map[uint32]*TLItem {} - -var itemsBytesByName = map[string]*TLItem {} - func SetGlobalFactoryCreateForFunction(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { item := itemsByTag[itemTag] if item == nil { @@ -319,7 +306,7 @@ func SetGlobalFactoryCreateForEnumElement(itemTag uint32) { } func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find function tag #%08x to set", itemTag)) } @@ -329,7 +316,7 @@ func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() } func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Object) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find item tag #%08x to set", itemTag)) } @@ -337,7 +324,7 @@ func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Ob } func SetGlobalFactoryCreateForEnumElementBytes(itemTag uint32) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find enum tag #%08x to set", itemTag)) } @@ -365,10 +352,6 @@ func fillObject(n1 string, n2 string, item *TLItem) { itemsByName[item.tlName] = item itemsByName[n1] = item itemsByName[n2] = item - itemsBytesByTag[item.tag] = item - itemsBytesByName[item.tlName] = item - itemsBytesByName[n1] = item - itemsBytesByName[n2] = item item.createObject = pleaseImportFactoryObject item.createObjectBytes = pleaseImportFactoryBytesObject // code below is as fast, but allocates some extra strings which are already in binary const segment due to JSON code diff --git a/internal/tlcodegen/test/gen/cases/meta/meta.go b/internal/tlcodegen/test/gen/cases/meta/meta.go index a1e46271..c61eeed2 100644 --- a/internal/tlcodegen/test/gen/cases/meta/meta.go +++ b/internal/tlcodegen/test/gen/cases/meta/meta.go @@ -92,14 +92,14 @@ func CreateObjectFromName(name string) Object { } func CreateFunctionBytes(tag uint32) Function { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil } func CreateObjectBytes(tag uint32) Object { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -107,7 +107,7 @@ func CreateObjectBytes(tag uint32) Object { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateFunctionFromNameBytes(name string) Function { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil @@ -115,7 +115,7 @@ func CreateFunctionFromNameBytes(name string) Function { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateObjectFromNameBytes(name string) Object { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -198,22 +198,10 @@ func FactoryItemByTLName(name string) *TLItem { return itemsByName[name] } -func FactoryItemByTLTagBytes(tag uint32) *TLItem { - return itemsBytesByTag[tag] -} - -func FactoryItemByTLNameBytes(name string) *TLItem { - return itemsBytesByName[name] -} - var itemsByTag = map[uint32]*TLItem{} var itemsByName = map[string]*TLItem{} -var itemsBytesByTag = map[uint32]*TLItem{} - -var itemsBytesByName = map[string]*TLItem{} - func SetGlobalFactoryCreateForFunction(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { item := itemsByTag[itemTag] if item == nil { @@ -241,7 +229,7 @@ func SetGlobalFactoryCreateForEnumElement(itemTag uint32) { } func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find function tag #%08x to set", itemTag)) } @@ -251,7 +239,7 @@ func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() } func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Object) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find item tag #%08x to set", itemTag)) } @@ -259,7 +247,7 @@ func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Ob } func SetGlobalFactoryCreateForEnumElementBytes(itemTag uint32) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find enum tag #%08x to set", itemTag)) } @@ -287,10 +275,6 @@ func fillObject(n1 string, n2 string, item *TLItem) { itemsByName[item.tlName] = item itemsByName[n1] = item itemsByName[n2] = item - itemsBytesByTag[item.tag] = item - itemsBytesByName[item.tlName] = item - itemsBytesByName[n1] = item - itemsBytesByName[n2] = item item.createObject = pleaseImportFactoryObject item.createObjectBytes = pleaseImportFactoryBytesObject // code below is as fast, but allocates some extra strings which are already in binary const segment due to JSON code diff --git a/internal/tlcodegen/test/gen/goldmaster/meta/meta.go b/internal/tlcodegen/test/gen/goldmaster/meta/meta.go index ca072efc..231d21e1 100644 --- a/internal/tlcodegen/test/gen/goldmaster/meta/meta.go +++ b/internal/tlcodegen/test/gen/goldmaster/meta/meta.go @@ -92,14 +92,14 @@ func CreateObjectFromName(name string) Object { } func CreateFunctionBytes(tag uint32) Function { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil } func CreateObjectBytes(tag uint32) Object { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -107,7 +107,7 @@ func CreateObjectBytes(tag uint32) Object { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateFunctionFromNameBytes(name string) Function { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil @@ -115,7 +115,7 @@ func CreateFunctionFromNameBytes(name string) Function { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateObjectFromNameBytes(name string) Object { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -200,22 +200,10 @@ func FactoryItemByTLName(name string) *TLItem { return itemsByName[name] } -func FactoryItemByTLTagBytes(tag uint32) *TLItem { - return itemsBytesByTag[tag] -} - -func FactoryItemByTLNameBytes(name string) *TLItem { - return itemsBytesByName[name] -} - var itemsByTag = map[uint32]*TLItem{} var itemsByName = map[string]*TLItem{} -var itemsBytesByTag = map[uint32]*TLItem{} - -var itemsBytesByName = map[string]*TLItem{} - func SetGlobalFactoryCreateForFunction(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { item := itemsByTag[itemTag] if item == nil { @@ -243,7 +231,7 @@ func SetGlobalFactoryCreateForEnumElement(itemTag uint32) { } func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find function tag #%08x to set", itemTag)) } @@ -253,7 +241,7 @@ func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() } func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Object) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find item tag #%08x to set", itemTag)) } @@ -261,7 +249,7 @@ func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Ob } func SetGlobalFactoryCreateForEnumElementBytes(itemTag uint32) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find enum tag #%08x to set", itemTag)) } @@ -289,10 +277,6 @@ func fillObject(n1 string, n2 string, item *TLItem) { itemsByName[item.tlName] = item itemsByName[n1] = item itemsByName[n2] = item - itemsBytesByTag[item.tag] = item - itemsBytesByName[item.tlName] = item - itemsBytesByName[n1] = item - itemsBytesByName[n2] = item item.createObject = pleaseImportFactoryObject item.createObjectBytes = pleaseImportFactoryBytesObject // code below is as fast, but allocates some extra strings which are already in binary const segment due to JSON code diff --git a/internal/tlcodegen/test/gen/goldmaster_nosplit/meta/meta.go b/internal/tlcodegen/test/gen/goldmaster_nosplit/meta/meta.go index 1b41e2f3..90f5954a 100644 --- a/internal/tlcodegen/test/gen/goldmaster_nosplit/meta/meta.go +++ b/internal/tlcodegen/test/gen/goldmaster_nosplit/meta/meta.go @@ -92,14 +92,14 @@ func CreateObjectFromName(name string) Object { } func CreateFunctionBytes(tag uint32) Function { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil } func CreateObjectBytes(tag uint32) Object { - if item := FactoryItemByTLTagBytes(tag); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLTag(tag); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -107,7 +107,7 @@ func CreateObjectBytes(tag uint32) Object { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateFunctionFromNameBytes(name string) Function { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createFunctionBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createFunctionBytes != nil { return item.createFunctionBytes() } return nil @@ -115,7 +115,7 @@ func CreateFunctionFromNameBytes(name string) Function { // name can be in any of 3 forms "ch_proxy.insert#7cf362ba", "ch_proxy.insert" or "#7cf362ba" func CreateObjectFromNameBytes(name string) Object { - if item := FactoryItemByTLNameBytes(name); item != nil && item.createObjectBytes != nil { + if item := FactoryItemByTLName(name); item != nil && item.createObjectBytes != nil { return item.createObjectBytes() } return nil @@ -200,22 +200,10 @@ func FactoryItemByTLName(name string) *TLItem { return itemsByName[name] } -func FactoryItemByTLTagBytes(tag uint32) *TLItem { - return itemsBytesByTag[tag] -} - -func FactoryItemByTLNameBytes(name string) *TLItem { - return itemsBytesByName[name] -} - var itemsByTag = map[uint32]*TLItem{} var itemsByName = map[string]*TLItem{} -var itemsBytesByTag = map[uint32]*TLItem{} - -var itemsBytesByName = map[string]*TLItem{} - func SetGlobalFactoryCreateForFunction(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { item := itemsByTag[itemTag] if item == nil { @@ -243,7 +231,7 @@ func SetGlobalFactoryCreateForEnumElement(itemTag uint32) { } func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() Object, createFunction func() Function, createFunctionLong func() Function) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find function tag #%08x to set", itemTag)) } @@ -253,7 +241,7 @@ func SetGlobalFactoryCreateForFunctionBytes(itemTag uint32, createObject func() } func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Object) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find item tag #%08x to set", itemTag)) } @@ -261,7 +249,7 @@ func SetGlobalFactoryCreateForObjectBytes(itemTag uint32, createObject func() Ob } func SetGlobalFactoryCreateForEnumElementBytes(itemTag uint32) { - item := itemsBytesByTag[itemTag] + item := itemsByTag[itemTag] if item == nil { panic(fmt.Sprintf("factory cannot find enum tag #%08x to set", itemTag)) } @@ -289,10 +277,6 @@ func fillObject(n1 string, n2 string, item *TLItem) { itemsByName[item.tlName] = item itemsByName[n1] = item itemsByName[n2] = item - itemsBytesByTag[item.tag] = item - itemsBytesByName[item.tlName] = item - itemsBytesByName[n1] = item - itemsBytesByName[n2] = item item.createObject = pleaseImportFactoryObject item.createObjectBytes = pleaseImportFactoryBytesObject // code below is as fast, but allocates some extra strings which are already in binary const segment due to JSON code