This commit is contained in:
aozhiwei 2024-06-16 14:26:20 +08:00
parent e109c6fbe6
commit 74446ec857
3 changed files with 7 additions and 11 deletions

View File

@ -13,7 +13,7 @@ type cacheMgr struct {
}
func (this *cacheMgr) Init() {
this.nftHash = new(q5.ConcurrentMap[string, *nft])
}
func (this *cacheMgr) UnInit() {

View File

@ -3,7 +3,6 @@ package mt
import (
"f5"
"mtb"
"sync"
"strings"
)
@ -13,7 +12,6 @@ type Contract struct {
type ContractTable struct {
f5.NameMetaTable[Contract]
itemHash sync.Map //string => Contract
}
func (this *Contract) Init1() {

View File

@ -3,30 +3,28 @@ package mt
import (
"f5"
"mtb"
"sync"
"strings"
)
type Item struct {
mtb.Item
lowerName string
}
type ItemTable struct {
f5.IdMetaTable[Item]
itemHash sync.Map //string => item_id
}
func (this *Item) Init1() {
Table.Item.itemHash.Store(strings.ToLower(this.GetName()), this.GetItemId())
this.lowerName = strings.ToLower(this.GetName())
}
func (this *ItemTable) Search(name string, itemIds map[int32]int32) {
name = strings.ToLower(name)
this.itemHash.Range(
func (k, v interface{}) bool {
key := k.(string)
if strings.Contains(key, name) {
itemIds[v.(int32)] = 1
this.Traverse(
func (ele *Item) bool {
if strings.Contains(ele.lowerName, name) {
itemIds[ele.GetItemId()] = 1
}
return true
})