- Home
- Downloads
-
Addons & Mods
Featured
World of Warcraft
6,103 Addons
-
Popular Downloads
- Top World of Warcraft Addons
- Top Minecraft Server Mods
- Top Rift Addons
- Top Skyrim Mods
- Top World of Tanks Skins
- Top StarCraft II Maps
- Top Terraria Maps
- Top Runes of Magic Addons
- Top Warhammer Online Addons
- Top The Secret World Mods
- Top Age of Conan Addons
-
- Curse Client
- Premium
- News
- Giveaways
- Forums
- Store
FindGlobals
- 0 Likes
- World of Warcraft
- 5 Monthly Downloads
- Supports: 3.3.0
- 919 Total Downloads
- Updated 11/06/2009
- Created 10/01/2009
- 4 Favorites
- Project Site
- Comments
- Release Type: Mature
- License: Public Domain
- Newest File: r3-beta
About FindGlobals
This is a Lua script that checks your .lua files for excess and/or involuntary global variable access.
It needs a Lua interpreter to run; I recommend Cogwheel's WoW Lua.
THIS IS NOT AN ADDON
PRO'S DIGEST
Yes, it's basically a "Luac | grep ?ETGLOBAL", but with some controls.
In PARTICULAR, it differentiates between set/get global access inside and outside of functions.
It also lets you list globals that you are ok with in comment lines like "--GLOBALS: blah, bleh, bluh".
So, it's a little more run-every-time-you-save-before-reloadui friendly. I've been using it for a bit and thought i'd share.
What do I need to know about globals for?
To optimize an addon's performance, you want to make access to commonly-used functions "local" access rather than global namespace lookups. This most definitely includes functions like type, next, pairs, select that maybe you didn't even realize were functions.
Some globals you may be okay with being global accesses (or in fact NEED them to because they can be hooked or changed), for those you have two options:
- Add one or more "
--GLOBALS: SomeFunc, SomeOtherFunc, SomeGlobalVariable" lines to the source file
or - Put a "local _G=_G" at the top of the file, and then access them through _G.SomeFunc, etc. This is actually somewhat faster than accessing them directly, believe it or not. (Direct global access involves looking up the global variable table first!)
Then, and this is possibly the biggest boon of the script, there is finding the odd miss-spelled variable name. Or the code snippet that you copy&pasted from one function to another but forgot to rename the variables. This rocks.
How to run
Put globals.lua in some directory. Maybe along with your Lua interpreter. Then:
luac -l -p MyFile.lua | lua globals.lua MyFile.lua
or, more likely:
c:\path\to\luac -l -p MyFile.lua | c:\path\to\lua c:\path\to\globals.lua MyFile.lua
Additionally
... since we're running Luac on the file, it is also checked for syntax errors.
I heartily recommend adding this as a "Tool" in your text editor of choice and binding it to a key that you can mash it to save & test before reloading your UI.
Oh and by the way, if you feel that this deserves a % of the curse points that go to libraries that you use, I'd appreciate a tools-used line in your .pkgmeta file :-)
------------------------------------------------------------------------
r4 | mikk | 2009-11-06 10:48:02 +0000 (Fri, 06 Nov 2009) | 1 line
Changed paths:
A /tags/r3-beta (from /trunk:3)
Tagging as r3-beta
------------------------------------------------------------------------
r3 | mikk | 2009-10-01 17:17:14 +0000 (Thu, 01 Oct 2009) | 1 line
Changed paths:
M /trunk/globals.lua
should run on non-cogwheel lua now too.. i think.
------------------------------------------------------------------------
| File Name | Release Type | Game Version | Downloads | Date |
|---|---|---|---|---|
| r3-beta | Beta | 3.3.0 | 907 | 11/06/2009 |
Top Downloads
-
- Deadly Boss Mods
- Combat, PvP, and Boss Encounters
- 1,129,948 Monthly Downloads
-
- Bagnon
- Bags & Inventory
- 498,005 Monthly Downloads
-
- Deadly Boss Mods - Burning Crusade and Vanilla mods
- Combat and Boss Encounters
- 335,742 Monthly Downloads
-
- Recount
- Combat
- 323,867 Monthly Downloads
-
- HealBot Continued
- Healer and Unit Frames
- 297,532 Monthly Downloads
Comments