mirror of
https://github.com/ceph/ceph
synced 2025-01-20 01:51:34 +00:00
Merge pull request #11958 from batrick/cls-lua-lua_next
lua: use simpler lua_next traversal structure Reviewed-by: John Spray <john.spray@redhat.com>
This commit is contained in:
commit
212b9737b8
@ -509,8 +509,7 @@ static int clslua_map_set_vals(lua_State *L)
|
||||
|
||||
map<string, bufferlist> kvpairs;
|
||||
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 1) != 0) {
|
||||
for (lua_pushnil(L); lua_next(L, 1); lua_pop(L, 1)) {
|
||||
/*
|
||||
* In the case of a numeric key a copy is made on the stack because
|
||||
* converting to a string would otherwise manipulate the original key and
|
||||
@ -553,8 +552,6 @@ static int clslua_map_set_vals(lua_State *L)
|
||||
}
|
||||
|
||||
kvpairs[key] = val;
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int ret = cls_cxx_map_set_vals(hctx, &kvpairs);
|
||||
|
@ -143,15 +143,13 @@ int Mantle::balance(const string &script,
|
||||
|
||||
/* fill in return value */
|
||||
mds_rank_t it = mds_rank_t(0);
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, -2) != 0) {
|
||||
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
|
||||
if (!lua_isnumber(L, -1)) {
|
||||
dout(0) << "WARNING: mantle script returned a malformed response" << dendl;
|
||||
lua_close(L);
|
||||
return -EINVAL;
|
||||
}
|
||||
my_targets[it] = (lua_tonumber(L, -1));
|
||||
lua_pop(L, 1);
|
||||
it++;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user