Skip to content

Commit

Permalink
Add explicit types in for loop variables
Browse files Browse the repository at this point in the history
Since we are now using a template type, this is no longer inferable by
an IDE. Adding explicit types also reduces the number of `.value()`
conversions required.
  • Loading branch information
tobil4sk committed Sep 13, 2024
1 parent 8a1bdde commit 6e51c8e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/luasimdjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ void convert_ondemand_element_to_table(lua_State *L, T element) {
int count = 1;
lua_newtable(L);

for (auto child : element.get_array()) {
for (ondemand::value child : element.get_array()) {
lua_pushinteger(L, count);
// We need the call to value() to get
// an ondemand::value type.
convert_ondemand_element_to_table(L, child.value());
convert_ondemand_element_to_table(L, child);
lua_settable(L, -3);
count = count + 1;
}
Expand All @@ -66,10 +64,10 @@ void convert_ondemand_element_to_table(lua_State *L, T element) {

case ondemand::json_type::object:
lua_newtable(L);
for (auto field : element.get_object()) {
for (ondemand::field field : element.get_object()) {
std::string_view s = field.unescaped_key();
lua_pushlstring(L, s.data(), s.size());
convert_ondemand_element_to_table(L, field.value().value());
convert_ondemand_element_to_table(L, field.value());
lua_settable(L, -3);
}
break;
Expand Down

0 comments on commit 6e51c8e

Please sign in to comment.