lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Learning Lua, I'm a bit puzzled with this test :

Could someone explain why the first script below is about 10%
faster than the second ?

Intuitively, I would have guessed the opposite.

Thanks
Thierry


     for y = y0 , y1 do
          for x = x0, x1 do
              local v = get_value(x,y)
              local r,g,b = get_rgb(x,y)
              <....../>
         end
     end

     local v, r,g,b
     for y = y0 , y1 do
          for x = x0, x1 do
              v = get_value(x,y)
              r,g,b = get_rgb(x,y)
              <....../>
         end
     end