To clarify, I didn't mean "localize it right before using it".
See http://wiki.luajit.org/Numerical-Comput ... ance-Guide the part about "Do not try to second-guess the JIT compiler."
Search found 478 matches
- Fri Nov 10, 2017 2:42 pm
- Forum: General
- Topic: Local iterator functions slower than global?
- Replies: 14
- Views: 12211
- Fri Nov 10, 2017 2:16 pm
- Forum: General
- Topic: Local iterator functions slower than global?
- Replies: 14
- Views: 12211
Re: Local iterator functions slower than global?
I would still test how fast localizing ipairs, pairs and next is when the locals used have the same names ... pairs() and ipairs() are called exactly once per loop, to generate the 3 variables used by the for loop. You'd save at most a single index operation on _G per loop. next() is called each it...
- Fri Nov 10, 2017 11:45 am
- Forum: General
- Topic: Local iterator functions slower than global?
- Replies: 14
- Views: 12211
Re: Local iterator functions slower than global?
http://wiki.luajit.org/Bytecode-2.0#calls-and-vararg-handling Note: The Lua parser heuristically determines whether pairs() or next() might be used in a loop. In this case, the JMP and the iterator call ITERC are replaced with the specialized versions ISNEXT and ITERN. ISNEXT verifies at runtime tha...
- Wed Nov 08, 2017 9:35 pm
- Forum: Support and Development
- Topic: Networking with lua? Making online games?
- Replies: 5
- Views: 7018
- Wed Nov 08, 2017 2:20 pm
- Forum: Support and Development
- Topic: math help
- Replies: 5
- Views: 5664
Re: math help
Here's a function that takes 2 points and rotates one around the other. local function rotatePoint(cx,cy,px,py,angle) local s = math.sin(angle) local c = math.cos(angle) px,py = px-cx,py-cy return px*c - py*s + cx,px*s + py*c + cy end function love.draw() local cx,cy = 100,100 --center of rotation l...
- Sun Nov 05, 2017 2:06 pm
- Forum: Support and Development
- Topic: Inaccurate results from Font:getWidth()
- Replies: 10
- Views: 9398
Re: Inaccurate results from Font:getWidth()
Played around with the undocumented rasterizer, managed to draw the actual outline of a letter. local testFont = love.graphics.newFont("Power.ttf", 128) local rasterizer = love.font.newRasterizer("Power.ttf",128) local glyphData = rasterizer:getGlyphData("A") for k,v in...
- Sun Nov 05, 2017 12:19 pm
- Forum: Support and Development
- Topic: Inaccurate results from Font:getWidth()
- Replies: 10
- Views: 9398
Re: Inaccurate results from Font:getWidth()
Post the font I'll give it a shot.
- Wed Nov 01, 2017 12:13 am
- Forum: Support and Development
- Topic: Trouble generating string-based seeds
- Replies: 2
- Views: 3352
Re: Trouble generating string-based seeds
Repeated string concatenation produces a lot of garbage for the garbage collector, work with bytes or use table.concat Here's a very bad string hashing function local maxSeed = 2^30 local function stringToSeed(s) local seed = 1 for i=1,s:len() do seed = (seed*31337 + s:byte(i))%maxSeed end return se...
- Mon Oct 30, 2017 12:46 pm
- Forum: Support and Development
- Topic: Anim8 Walking Animation using keys returning nil
- Replies: 2
- Views: 3740
Re: Anim8 Walking Animation using keys returning nil
Code: Select all
function love.update(dt)
if love.keyboard.isDown('a') then
current_animation = animations.left
current_animation:update(dt)
end
end
- Fri Oct 27, 2017 4:53 pm
- Forum: Support and Development
- Topic: [SOLVED : anim8] : corrupt or error? (display a pink rect)
- Replies: 4
- Views: 4878
Re: [anim8] : corrupt or error?
Your image is 13500 pixels wide. See https://love2d.org/wiki/love.graphics.getSystemLimits