Re: Array performance with 2.0.0-beta10 versus git HEAD

  • From: Mike Pall <mike-1208@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 29 Aug 2012 00:39:26 +0200

Peter Colberg wrote:
> The reason for prefering int over unsigned int being that a possible
> overflow of an unsigned loop variable could hinder the compiler in
> optimising a loop?

The Lua number type is a double (or int/double, depending on the
architecture). It's much easier for the JIT compiler to handle
plain int than uint32_t or uint64_t. Also, conversions between
double and unsigned types are slow on many platforms.

> > typedef struct vec3_array { int size; vec3 data[?]; } vec3_array;
> > ...
> > local array = vec3_array(size, size)
> But then the program would be subject to the 2GB limit, no?

Yep. So for your use case better malloc a separate array.


Other related posts: