mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-11 00:40:00 +08:00
perf: pre-allocate all known length arrays to avoid re-scaling (#5029)
Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a2b98dbcf7
commit
130e1ba963
@@ -39,7 +39,7 @@ type Join []string
|
||||
|
||||
func genCacheKeys(prefix string, table parser.Table) (Key, []Key) {
|
||||
var primaryKey Key
|
||||
var uniqueKey []Key
|
||||
uniqueKey := make([]Key, 0, len(table.UniqueIndex))
|
||||
primaryKey = genCacheKey(prefix, table.Db, table.Name, []*parser.Field{&table.PrimaryKey.Field})
|
||||
for _, each := range table.UniqueIndex {
|
||||
uniqueKey = append(uniqueKey, genCacheKey(prefix, table.Db, table.Name, each))
|
||||
|
||||
Reference in New Issue
Block a user