** Returns the real size of the 'array' array */
| 248 | ** Returns the real size of the 'array' array |
| 249 | */ |
| 250 | LUAI_FUNC unsigned int luaH_realasize (const Table *t) { |
| 251 | if (limitequalsasize(t)) |
| 252 | return t->alimit; /* this is the size */ |
| 253 | else { |
| 254 | unsigned int size = t->alimit; |
| 255 | /* compute the smallest power of 2 not smaller than 'size' */ |
| 256 | size |= (size >> 1); |
| 257 | size |= (size >> 2); |
| 258 | size |= (size >> 4); |
| 259 | size |= (size >> 8); |
| 260 | #if (UINT_MAX >> 14) > 3 /* unsigned int has more than 16 bits */ |
| 261 | size |= (size >> 16); |
| 262 | #if (UINT_MAX >> 30) > 3 |
| 263 | size |= (size >> 32); /* unsigned int has more than 32 bits */ |
| 264 | #endif |
| 265 | #endif |
| 266 | size++; |
| 267 | lua_assert(ispow2(size) && size/2 < t->alimit && t->alimit < size); |
| 268 | return size; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | |
| 273 | /* |
no outgoing calls
no test coverage detected