Skip to content

Commit d76736e

Browse files
authored
Asseorted set of fixes (#234)
1 parent d4d57cc commit d76736e

12 files changed

Lines changed: 839 additions & 107 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ Build/
1111
*.vcxproj.filters
1212
*.vcxproj.user
1313
.vs/
14-
.vscode
15-
.DS_store
14+
.vscode/
1615
.idea/
16+
.gitnexus/
17+
.DS_Store
1718
cmake-build-*/
1819
tmpunwind.o

‎Benchmarks/benchmark_luabridge3.cpp‎

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,8 @@ void optional_success_measure(benchmark::State& state)
397397
for (auto _ : state)
398398
{
399399
(void) _;
400-
luabridge::LuaRef warble = luabridge::getGlobal(L, "warble");
401-
if (warble.isTable())
402-
{
403-
auto result = warble.getField<double>("value");
404-
x += result ? *result : 1.0;
405-
}
406-
else
407-
x += 1.0;
400+
auto result = luabridge::tryGetGlobalField<double>(L, "warble", "value");
401+
x += result ? *result : 1.0;
408402
}
409403

410404
benchmark::DoNotOptimize(x);
@@ -419,14 +413,8 @@ void optional_half_failure_measure(benchmark::State& state)
419413
for (auto _ : state)
420414
{
421415
(void) _;
422-
luabridge::LuaRef warble = luabridge::getGlobal(L, "warble");
423-
if (warble.isTable())
424-
{
425-
auto result = warble.getField<double>("value");
426-
x += result ? *result : 1.0;
427-
}
428-
else
429-
x += 1.0;
416+
auto result = luabridge::tryGetGlobalField<double>(L, "warble", "value");
417+
x += result ? *result : 1.0;
430418
}
431419

432420
benchmark::DoNotOptimize(x);
@@ -440,14 +428,8 @@ void optional_failure_measure(benchmark::State& state)
440428
for (auto _ : state)
441429
{
442430
(void) _;
443-
luabridge::LuaRef warble = luabridge::getGlobal(L, "warble");
444-
if (warble.isTable())
445-
{
446-
auto result = warble.getField<double>("value");
447-
x += result ? *result : 1.0;
448-
}
449-
else
450-
x += 1.0;
431+
auto result = luabridge::tryGetGlobalField<double>(L, "warble", "value");
432+
x += result ? *result : 1.0;
451433
}
452434

453435
benchmark::DoNotOptimize(x);

0 commit comments

Comments
 (0)