Skip to content

Commit 48a3bee

Browse files
att
1 parent 9aa767d commit 48a3bee

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

LuaCEmbed.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24211,15 +24211,13 @@ bool LuaCembedTable_has_key_at_index(LuaCEmbedTable *self, long index){
2421124211
lua_pushnil(self->main_object->state);
2421224212
while(lua_next(self->main_object->state,table_index)){
2421324213
if(total == converted_index){
24214-
if(lua_type(self->main_object->state,-2) != LUA_CEMBED_STRING ){
24215-
return false;
24216-
}
24217-
return true;
24214+
bool has_key =lua_type(self->main_object->state,-2) == LUA_CEMBED_STRING;
24215+
lua_pop(self->main_object->state,1);
24216+
return has_key;
2421824217
}
2421924218

2422024219
lua_pop(self->main_object->state,1);
2422124220
total+=1;
24222-
2422324221
}
2422424222

2422524223
return false;
@@ -24228,7 +24226,6 @@ bool LuaCembedTable_has_key_at_index(LuaCEmbedTable *self, long index){
2422824226
long long LuaCEmbedTable_get_long_by_index(LuaCEmbedTable *self, int index){
2422924227
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
2423024228
private_lua_cembed_memory_limit = self->main_object->memory_limit;
24231-
2423224229
int formatted_index = index + LUA_CEMBED_INDEX_DIF;
2423324230

2423424231
lua_getglobal(self->main_object->state,self->global_name);

src/LuaCEmbed/table/table/getters/index/index.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,13 @@ bool LuaCembedTable_has_key_at_index(LuaCEmbedTable *self, long index){
106106
lua_pushnil(self->main_object->state);
107107
while(lua_next(self->main_object->state,table_index)){
108108
if(total == converted_index){
109-
if(lua_type(self->main_object->state,-2) != LUA_CEMBED_STRING ){
110-
return false;
111-
}
112-
return true;
109+
bool has_key =lua_type(self->main_object->state,-2) == LUA_CEMBED_STRING;
110+
lua_pop(self->main_object->state,1);
111+
return has_key;
113112
}
114113

115114
lua_pop(self->main_object->state,1);
116115
total+=1;
117-
118116
}
119117

120118
return false;
@@ -123,7 +121,6 @@ bool LuaCembedTable_has_key_at_index(LuaCEmbedTable *self, long index){
123121
long long LuaCEmbedTable_get_long_by_index(LuaCEmbedTable *self, int index){
124122
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
125123
private_lua_cembed_memory_limit = self->main_object->memory_limit;
126-
127124
int formatted_index = index + LUA_CEMBED_INDEX_DIF;
128125

129126
lua_getglobal(self->main_object->state,self->global_name);

tests/LuaCEmbed.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24211,15 +24211,13 @@ bool LuaCembedTable_has_key_at_index(LuaCEmbedTable *self, long index){
2421124211
lua_pushnil(self->main_object->state);
2421224212
while(lua_next(self->main_object->state,table_index)){
2421324213
if(total == converted_index){
24214-
if(lua_type(self->main_object->state,-2) != LUA_CEMBED_STRING ){
24215-
return false;
24216-
}
24217-
return true;
24214+
bool has_key =lua_type(self->main_object->state,-2) == LUA_CEMBED_STRING;
24215+
lua_pop(self->main_object->state,1);
24216+
return has_key;
2421824217
}
2421924218

2422024219
lua_pop(self->main_object->state,1);
2422124220
total+=1;
24222-
2422324221
}
2422424222

2422524223
return false;
@@ -24228,7 +24226,6 @@ bool LuaCembedTable_has_key_at_index(LuaCEmbedTable *self, long index){
2422824226
long long LuaCEmbedTable_get_long_by_index(LuaCEmbedTable *self, int index){
2422924227
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
2423024228
private_lua_cembed_memory_limit = self->main_object->memory_limit;
24231-
2423224229
int formatted_index = index + LUA_CEMBED_INDEX_DIF;
2423324230

2423424231
lua_getglobal(self->main_object->state,self->global_name);

0 commit comments

Comments
 (0)