Skip to content

Commit

Permalink
refactor: use l.geti l.seti
Browse files Browse the repository at this point in the history
  • Loading branch information
peacalm committed Jun 18, 2023
1 parent 9bc686a commit 4f65fb4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions include/peacalm/luaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,12 @@ class luaw {
self_t& touchtb(int n, int idx = -1) {
int aidx = abs_index(idx);
PEACALM_LUAW_INDEXABLE_ASSERT(indexable_and_newindexable(aidx));
lua_geti(L_, aidx, n);
geti(aidx, n);
if (istable() || indexable_and_newindexable()) return *this;
pop();
lua_newtable(L_);
lua_seti(L_, aidx, n);
lua_geti(L_, aidx, n);
seti(aidx, n);
geti(aidx, n);
return *this;
}

Expand Down Expand Up @@ -976,7 +976,7 @@ class luaw {
PEACALM_LUAW_INDEXABLE_ASSERT(newindexable(idx));
int aidx = abs_index(idx);
push(std::forward<T>(value));
lua_seti(L_, aidx, key);
seti(aidx, key);
}
template <typename T>
void setkv(void* key, T&& value, int idx = -1) {
Expand Down Expand Up @@ -1011,7 +1011,7 @@ class luaw {
PEACALM_LUAW_INDEXABLE_ASSERT(newindexable(idx));
int aidx = abs_index(idx);
push<Hint>(std::forward<T>(value));
lua_seti(L_, aidx, key);
seti(aidx, key);
}
template <typename Hint, typename T>
std::enable_if_t<!std::is_same<Hint, T>::value> setkv(void* key,
Expand Down Expand Up @@ -3074,10 +3074,10 @@ struct luaw::convertor<std::pair<T, U>> {
}
// Allow elements do not exist, {} means a pair with initial values
bool ffailed, sfailed;
lua_geti(l.L(), idx, 1);
l.geti(idx, 1);
auto first = luaw::convertor<T>::to(l, -1, disable_log, &ffailed);
l.pop();
lua_geti(l.L(), idx, 2);
l.geti(idx, 2);
auto second = luaw::convertor<U>::to(l, -1, disable_log, &sfailed);
l.pop();
if (failed) *failed = (ffailed || sfailed);
Expand Down Expand Up @@ -3110,7 +3110,7 @@ struct luaw::convertor<std::vector<T, Allocator>> {
int sz = luaL_len(l.L(), idx);
ret.reserve(sz);
for (int i = 1; i <= sz; ++i) {
lua_geti(l.L(), idx, i);
l.geti(idx, i);
bool subfailed, subexists;
auto subret =
luaw::convertor<T>::to(l, -1, disable_log, &subfailed, &subexists);
Expand Down

0 comments on commit 4f65fb4

Please sign in to comment.