| 1539 | } |
| 1540 | |
| 1541 | void LuaDetail::jcontResize(LuaTable const& table, size_t targetSize) { |
| 1542 | if (auto mt = table.getMetatable()) { |
| 1543 | if (auto nils = mt->rawGet<Maybe<LuaTable>>("__nils")) { |
| 1544 | nils->iterate([&](LuaValue const& key, LuaValue const&) { |
| 1545 | auto i = asInteger(key); |
| 1546 | if (i && *i > 0 && (size_t)*i > targetSize) |
| 1547 | nils->rawSet(key, LuaNil); |
| 1548 | }); |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | table.iterate([&](LuaValue const& key, LuaValue const&) { |
| 1553 | auto i = asInteger(key); |
| 1554 | if (i && *i > 0 && (size_t)*i > targetSize) |
| 1555 | table.rawSet(key, LuaNil); |
| 1556 | }); |
| 1557 | |
| 1558 | table.set(targetSize, table.get(targetSize)); |
| 1559 | } |
| 1560 | |
| 1561 | Maybe<LuaInt> LuaDetail::asInteger(LuaValue const& v) { |
| 1562 | if (v.is<LuaInt>()) |
nothing calls this directly
no test coverage detected