Closed agladysh closed 13 years ago
Also, I find these accesses to zmq
constant fields a bit strange — given that require 'zmq'
is nowhere to be found in this code. This probably works due to some implementation details in your FFI bindings generator, but I would at least leave a comment there, describing what is going on.
Fixed incorrect use of global for ud_obj
variable. Also localized some of the other global access that needed it. Most of those global accesses are only during the loading of the zmq FFI bindings and there is no need to localize them at the top of the file.
The FFI bindings over-write part of the normal Lua C API bindings, so those constants are define in the C code before the FFI bindings are loaded.
Thank you, fix confirmed!
By analyzing
luac -l
output, I found one variable that is regularly accessed via{S,G}ETGLOBAL
in lua-zmq FFI bindings —ud_obj
:Number in square brackets is line number in
zmq.dump_ffi()
output.Note that this may be a false positive if you prepend some kind of header with
local ud_obj
declaration before loading this code.Also, a small nitpicking observation: there is a lot of non-aliased global variables used (see full dump below). It is a better style to alias all this stuff to locals on the top of the file — this really helps if code is being run inside sandboxed environment. (Not that I plan to do so with zmq right now, but anyway.)