koreader/koreader — pull request #334 by hwhw (2013-10-22 20:06:34+00:00)
Title: Refactoring: Make globals local

This is a rather large change - however, what it does is quite simple:
- no more putting stuff into the global namespace
- rather require() everything into a local variable
- this allows LuaJIT to intern references rather than looking up everything upon use, which speeds things up (in theory, by large quantities, however this is still a bit restricted for every call into the Lua/C API)

A few things needed to be adapted:
- "combined" source files (like e.g. container.lua) was split up into one file per "class"
- DEBUG is now the __call method of the "Dbg" class, thus can be used by 'local DEBUG=require("dbg")'
- no more extending the math.* namespace, rather use Math.*
- Screen is now in Device.screen (to avoid circular dependency between both), but can still be used via "local Screen=require("ui/screen")"
- readtext is not global anymore, too: "local _ = require("gettext")" is needed