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() { func (this *cacheMgr) Init() {
this.nftHash = new(q5.ConcurrentMap[string, *nft])
} }
func (this *cacheMgr) UnInit() { func (this *cacheMgr) UnInit() {

View File

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

View File

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