box/lua: eliminate luaL_register*() usages in box
The idea of the refactoring is described in a previous commit. The change is straightforward: * Use `luaL_findtable()` to find/create a nested table in `_G`. * Use `luaL_setfuncs()` to assign functions to a table. * Use `luaT_newmodule()` to register a module for `require()`. `require('box.internal.<...>')` calls are replaced with `box.internal.<...>`, because `box` submodules are not registered as modules anymore (IOW, are not placed into `package.loaded`). However `_G.box == require('box')`, it remains unchanged. One may wonder why fourth argument of `luaL_findtable()` (size hint for the hash part of the table) is always zero in the added calls. It is an effect of the following points: * Those calls are not on hot paths and, moreover, there is no sense to use `luaL_findtable()` with a string literal as the second argument on a hot path (no sense to parse the string literal in runtime if a performance is the goal). * Using `lengthof()` macro would add more code to read for a human (the argument itself, a line carry to fit 80 symbols, an inclusion of trivia/util.h) at no gain. * A hardcoded array length is a developer's stress factor: it looks like it requires an update at a change of the array. So zero is better. Part of #7774 NO_DOC=user visible behavior is unchanged, pure refactoring change NO_TEST=see NO_DOC NO_CHANGELOG=see NO_DOC
Showing
- src/box/lua/call.c 2 additions, 1 deletionsrc/box/lua/call.c
- src/box/lua/cfg.cc 2 additions, 1 deletionsrc/box/lua/cfg.cc
- src/box/lua/console.c 1 addition, 1 deletionsrc/box/lua/console.c
- src/box/lua/console.lua 2 additions, 3 deletionssrc/box/lua/console.lua
- src/box/lua/ctl.c 2 additions, 1 deletionsrc/box/lua/ctl.c
- src/box/lua/error.cc 3 additions, 6 deletionssrc/box/lua/error.cc
- src/box/lua/index.c 3 additions, 6 deletionssrc/box/lua/index.c
- src/box/lua/info.c 3 additions, 8 deletionssrc/box/lua/info.c
- src/box/lua/init.c 9 additions, 4 deletionssrc/box/lua/init.c
- src/box/lua/key_def.c 1 addition, 1 deletionsrc/box/lua/key_def.c
- src/box/lua/lib.c 2 additions, 1 deletionsrc/box/lua/lib.c
- src/box/lua/load_cfg.lua 1 addition, 1 deletionsrc/box/lua/load_cfg.lua
- src/box/lua/merger.c 1 addition, 1 deletionsrc/box/lua/merger.c
- src/box/lua/misc.cc 2 additions, 1 deletionsrc/box/lua/misc.cc
- src/box/lua/net_box.c 1 addition, 7 deletionssrc/box/lua/net_box.c
- src/box/lua/net_box.lua 1 addition, 2 deletionssrc/box/lua/net_box.lua
- src/box/lua/schema.lua 1 addition, 1 deletionsrc/box/lua/schema.lua
- src/box/lua/sequence.c 2 additions, 1 deletionsrc/box/lua/sequence.c
- src/box/lua/session.c 4 additions, 2 deletionssrc/box/lua/session.c
- src/box/lua/space.cc 2 additions, 1 deletionsrc/box/lua/space.cc
Loading
Please register or sign in to comment