LuaJIT
#11
Of course I know that locals are faster. If I didn't know that my plugins would be awfully slowTongue But what you're using here isn't OOP. You're just getting a static function, putting it in a variable and calling. That won't work well with actuall methods. For example, look at the code I used for my test:
Code:

local MyClass = {}

function MyClass:new()
	local Obj = {}
	setmetatable(Obj, self)
	self.__index = self
	
	Obj.TestVar = math.random(50)
	
	return Obj
end

function MyClass:Test()
	local R = self.TestVar + 50
end

local startTime = os.clock()
local Constr = MyClass:new()
for I = 1, 1000000000 do
	Constr:Test()
end
print(os.clock() - startTime);


It's a really simple example of a class in Lua. What I could do is get the "Test" function and make it a local. Then give the object as a parameter, but how are you planning on making the TestVar variable a local? It's also of course not pretty to use that.
Reply
Thanks given by:


Messages In This Thread
LuaJIT - by worktycho - 03-24-2014, 03:12 AM
RE: LuaJIT - by worktycho - 03-24-2014, 04:14 AM
RE: LuaJIT - by xoft - 03-24-2014, 05:11 AM
RE: LuaJIT - by worktycho - 03-24-2014, 07:37 AM
RE: LuaJIT - by NiLSPACE - 03-30-2014, 07:28 AM
RE: LuaJIT - by xoft - 03-30-2014, 09:58 AM
RE: LuaJIT - by bearbin - 03-31-2014, 12:31 AM
RE: LuaJIT - by worktycho - 03-31-2014, 02:15 AM
RE: LuaJIT - by NiLSPACE - 12-26-2015, 09:56 PM
RE: LuaJIT - by LogicParrot - 12-26-2015, 11:02 PM
RE: LuaJIT - by NiLSPACE - 12-26-2015, 11:11 PM
RE: LuaJIT - by LogicParrot - 12-26-2015, 11:19 PM
RE: LuaJIT - by NiLSPACE - 12-26-2015, 11:23 PM
RE: LuaJIT - by LogicParrot - 12-26-2015, 11:24 PM
RE: LuaJIT - by LogicParrot - 12-26-2015, 11:38 PM
RE: LuaJIT - by NiLSPACE - 12-26-2015, 11:57 PM
RE: LuaJIT - by NiLSPACE - 12-27-2015, 11:40 PM
RE: LuaJIT - by NiLSPACE - 12-28-2015, 04:05 AM
RE: LuaJIT - by worktycho - 12-28-2015, 08:47 AM
RE: LuaJIT - by LogicParrot - 12-28-2015, 09:23 AM
RE: LuaJIT - by worktycho - 12-28-2015, 09:25 AM



Users browsing this thread: 1 Guest(s)