lua: preallocate tables with appropriate capacities

This commit is contained in:
Meo597
2026-10-05 04:29:01 +08:00
parent 37d9894dde
commit 54610a39a5
4 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ func (r *Router) RegisterLua(L *lua.LState) {
registerLuaContext(L)
L.PreloadModule("xray.router", func(L *lua.LState) int {
module := L.NewTable()
module := L.CreateTable(0, 7)
module.RawSetString("NetworkUnknown", lua.LNumber(net.Network_Unknown))
module.RawSetString("NetworkTCP", lua.LNumber(net.Network_TCP))
@@ -73,7 +73,7 @@ func registerLuaContext(L *lua.LState) {
}
return 1
}))
methods := L.NewTable()
methods := L.CreateTable(0, 4)
L.SetFuncs(methods, map[string]lua.LGFunction{
"GetSourceIPs": func(L *lua.LState) int {
xlua.PushUserData(L, checkLuaContext(L).GetSourceIPs())