Skip to content

Commit b6b7151

Browse files
authored
Merge pull request #2353 from joto/misc-cleanups
Miscellaneous refactorings
2 parents 78efdf9 + 7f5da49 commit b6b7151

12 files changed

+36
-37
lines changed

src/expire-output.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ class expire_output_t
2929
public:
3030
expire_output_t() = default;
3131

32-
std::string filename() const noexcept { return m_filename; }
32+
std::string const &filename() const noexcept { return m_filename; }
3333

3434
void set_filename(std::string filename)
3535
{
3636
m_filename = std::move(filename);
3737
}
3838

39-
std::string schema() const noexcept { return m_schema; }
39+
std::string const &schema() const noexcept { return m_schema; }
4040

41-
std::string table() const noexcept { return m_table; }
41+
std::string const &table() const noexcept { return m_table; }
4242

4343
void set_schema_and_table(std::string schema, std::string table)
4444
{

src/flex-lua-expire-output.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,31 +138,31 @@ int lua_wrapper_expire_output::tostring() const
138138
return 1;
139139
}
140140

141-
int lua_wrapper_expire_output::filename() const
141+
int lua_wrapper_expire_output::filename() const noexcept
142142
{
143143
luaX_pushstring(lua_state(), self().filename());
144144
return 1;
145145
}
146146

147-
int lua_wrapper_expire_output::maxzoom() const
147+
int lua_wrapper_expire_output::maxzoom() const noexcept
148148
{
149149
lua_pushinteger(lua_state(), self().maxzoom());
150150
return 1;
151151
}
152152

153-
int lua_wrapper_expire_output::minzoom() const
153+
int lua_wrapper_expire_output::minzoom() const noexcept
154154
{
155155
lua_pushinteger(lua_state(), self().minzoom());
156156
return 1;
157157
}
158158

159-
int lua_wrapper_expire_output::schema() const
159+
int lua_wrapper_expire_output::schema() const noexcept
160160
{
161161
luaX_pushstring(lua_state(), self().schema());
162162
return 1;
163163
}
164164

165-
int lua_wrapper_expire_output::table() const
165+
int lua_wrapper_expire_output::table() const noexcept
166166
{
167167
luaX_pushstring(lua_state(), self().table());
168168
return 1;

src/flex-lua-expire-output.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class lua_wrapper_expire_output : public lua_wrapper_base<expire_output_t>
3737
}
3838

3939
int tostring() const;
40-
int filename() const;
41-
int maxzoom() const;
42-
int minzoom() const;
43-
int schema() const;
44-
int table() const;
40+
int filename() const noexcept;
41+
int maxzoom() const noexcept;
42+
int minzoom() const noexcept;
43+
int schema() const noexcept;
44+
int table() const noexcept;
4545

4646
}; // class lua_wrapper_expire_output
4747

src/flex-lua-locator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int lua_wrapper_locator::tostring() const
104104
return 1;
105105
}
106106

107-
int lua_wrapper_locator::name() const
107+
int lua_wrapper_locator::name() const noexcept
108108
{
109109
luaX_pushstring(lua_state(), self().name());
110110
return 1;
@@ -158,7 +158,7 @@ int lua_wrapper_locator::all_intersecting()
158158
int n = 0;
159159
for (auto const& name : names) {
160160
lua_pushinteger(lua_state(), ++n);
161-
lua_pushstring(lua_state(), name.c_str());
161+
luaX_pushstring(lua_state(), name);
162162
lua_rawset(lua_state(), -3);
163163
}
164164

@@ -182,7 +182,7 @@ int lua_wrapper_locator::first_intersecting()
182182
return 0;
183183
}
184184

185-
lua_pushstring(lua_state(), name.c_str());
185+
luaX_pushstring(lua_state(), name);
186186

187187
return 1;
188188
}

src/flex-lua-locator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class lua_wrapper_locator : public lua_wrapper_base<locator_t>
3939
}
4040

4141
int tostring() const;
42-
int name() const;
42+
int name() const noexcept;
4343
int add_bbox();
4444
int add_from_db();
4545
int all_intersecting();

src/flex-lua-table.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ int lua_wrapper_table::tostring() const
488488
return 1;
489489
}
490490

491-
int lua_wrapper_table::cluster() const
491+
int lua_wrapper_table::cluster() const noexcept
492492
{
493493
lua_pushboolean(lua_state(), self().cluster_by_geom());
494494
return 1;
@@ -503,12 +503,11 @@ int lua_wrapper_table::columns() const
503503
lua_pushinteger(lua_state(), ++n);
504504
lua_newtable(lua_state());
505505

506-
luaX_add_table_str(lua_state(), "name", column.name().c_str());
507-
luaX_add_table_str(lua_state(), "type", column.type_name().c_str());
508-
luaX_add_table_str(lua_state(), "sql_type",
509-
column.sql_type_name().c_str());
506+
luaX_add_table_str(lua_state(), "name", column.name());
507+
luaX_add_table_str(lua_state(), "type", column.type_name());
508+
luaX_add_table_str(lua_state(), "sql_type", column.sql_type_name());
510509
luaX_add_table_str(lua_state(), "sql_modifiers",
511-
column.sql_modifiers().c_str());
510+
column.sql_modifiers());
512511
luaX_add_table_bool(lua_state(), "not_null", column.not_null());
513512
luaX_add_table_bool(lua_state(), "create_only", column.create_only());
514513

@@ -518,13 +517,13 @@ int lua_wrapper_table::columns() const
518517
return 1;
519518
}
520519

521-
int lua_wrapper_table::name() const
520+
int lua_wrapper_table::name() const noexcept
522521
{
523522
luaX_pushstring(lua_state(), self().name());
524523
return 1;
525524
}
526525

527-
int lua_wrapper_table::schema() const
526+
int lua_wrapper_table::schema() const noexcept
528527
{
529528
luaX_pushstring(lua_state(), self().schema());
530529
return 1;

src/flex-lua-table.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class lua_wrapper_table : public lua_wrapper_base<flex_table_t>
3737
}
3838

3939
int tostring() const;
40-
int cluster() const;
40+
int cluster() const noexcept;
4141
int columns() const;
42-
int name() const;
43-
int schema() const;
42+
int name() const noexcept;
43+
int schema() const noexcept;
4444

4545
}; // class lua_wrapper_table
4646

src/lua-setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void setup_lua_environment(lua_State *lua_state, std::string const &filename,
3333
if (!dir_path.empty()) {
3434
dir_path += std::filesystem::path::preferred_separator;
3535
}
36-
luaX_add_table_str(lua_state, "config_dir", dir_path.c_str());
36+
luaX_add_table_str(lua_state, "config_dir", dir_path);
3737

3838
luaX_add_table_str(lua_state, "mode", append_mode ? "append" : "create");
3939
}

src/lua-utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ void luaX_add_table_str(lua_State *lua_state, char const *key,
7676
}
7777

7878
void luaX_add_table_str(lua_State *lua_state, char const *key,
79-
char const *value, std::size_t size) noexcept
79+
std::string_view value) noexcept
8080
{
8181
lua_pushstring(lua_state, key);
82-
lua_pushlstring(lua_state, value, size);
82+
luaX_pushstring(lua_state, value);
8383
lua_rawset(lua_state, -3);
8484
}
8585

src/lua-utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void luaX_pushstring(lua_State *lua_state, std::string_view str) noexcept;
2828
void luaX_add_table_str(lua_State *lua_state, char const *key,
2929
char const *value) noexcept;
3030
void luaX_add_table_str(lua_State *lua_state, char const *key,
31-
char const *value, std::size_t size) noexcept;
31+
std::string_view value) noexcept;
3232
void luaX_add_table_int(lua_State *lua_state, char const *key,
3333
int64_t value) noexcept;
3434
void luaX_add_table_num(lua_State *lua_state, char const *key,

0 commit comments

Comments
 (0)