Skip to content

Commit e5b5c91

Browse files
committed
Make setup_flex_table_columns() easier to follow
By not clearing the Lua stack only at the end.
1 parent f5971f6 commit e5b5c91

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/output-flex.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,17 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table)
608608
lua_state(), "sql_type", -3, "Column entry", "");
609609

610610
auto &column = table->add_column(name, type, sql_type);
611+
lua_pop(lua_state(), 3); // "type", "column", "sql_type"
611612

612-
column.set_not_null(luaX_get_table_bool(lua_state(), "not_null", -4,
613+
column.set_not_null(luaX_get_table_bool(lua_state(), "not_null", -1,
613614
"Entry 'not_null'", false));
615+
lua_pop(lua_state(), 1); // "not_null"
614616

615617
column.set_create_only(luaX_get_table_bool(
616-
lua_state(), "create_only", -5, "Entry 'create_only'", false));
618+
lua_state(), "create_only", -1, "Entry 'create_only'", false));
619+
lua_pop(lua_state(), 1); // "create_only"
617620

618-
lua_getfield(lua_state(), -6, "projection");
621+
lua_getfield(lua_state(), -1, "projection");
619622
if (!lua_isnil(lua_state(), -1)) {
620623
if (column.is_geometry_column() ||
621624
column.type() == table_column_type::area) {
@@ -625,9 +628,8 @@ void output_flex_t::setup_flex_table_columns(flex_table_t *table)
625628
"geometry and area columns."};
626629
}
627630
}
631+
lua_pop(lua_state(), 1); // "projection"
628632

629-
// stack has: projection, create_only, not_null, sql_type, column, type
630-
lua_pop(lua_state(), 6);
631633
++num_columns;
632634
});
633635

0 commit comments

Comments
 (0)