@@ -881,38 +881,32 @@ void Dir_iterEnd(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc) {
881
881
}
882
882
883
883
int Dir_iterNext (JSOBJ _obj , JSONTypeContext * tc ) {
884
- PyObject * obj = (PyObject * )_obj ;
885
- PyObject * itemValue = GET_TC (tc )-> itemValue ;
886
- PyObject * itemName = GET_TC (tc )-> itemName ;
887
- PyObject * attr ;
888
- PyObject * attrName ;
889
- char * attrStr ;
890
-
891
884
if (PyErr_Occurred () || ((JSONObjectEncoder * )tc -> encoder )-> errorMsg ) {
892
885
return 0 ;
893
886
}
894
887
895
- if (itemValue ) {
888
+ if (GET_TC ( tc ) -> itemValue ) {
896
889
Py_DECREF (GET_TC (tc )-> itemValue );
897
- GET_TC (tc )-> itemValue = itemValue = NULL ;
890
+ GET_TC (tc )-> itemValue = NULL ;
898
891
}
899
892
900
- if (itemName ) {
893
+ if (GET_TC ( tc ) -> itemName ) {
901
894
Py_DECREF (GET_TC (tc )-> itemName );
902
- GET_TC (tc )-> itemName = itemName = NULL ;
895
+ GET_TC (tc )-> itemName = NULL ;
903
896
}
904
897
905
898
for (; GET_TC (tc )-> index < GET_TC (tc )-> size ; GET_TC (tc )-> index ++ ) {
906
- attrName = PyList_GET_ITEM (GET_TC (tc )-> attrList , GET_TC (tc )-> index );
907
- attr = PyUnicode_AsUTF8String (attrName );
908
- attrStr = PyBytes_AS_STRING (attr );
899
+ PyObject * attrName =
900
+ PyList_GET_ITEM (GET_TC (tc )-> attrList , GET_TC (tc )-> index );
901
+ PyObject * attr = PyUnicode_AsUTF8String (attrName );
902
+ char * attrStr = PyBytes_AS_STRING (attr );
909
903
910
904
if (attrStr [0 ] == '_' ) {
911
905
Py_DECREF (attr );
912
906
continue ;
913
907
}
914
908
915
- itemValue = PyObject_GetAttr (obj , attrName );
909
+ PyObject * itemValue = PyObject_GetAttr (( PyObject * ) _obj , attrName );
916
910
if (itemValue == NULL ) {
917
911
PyErr_Clear ();
918
912
Py_DECREF (attr );
@@ -925,24 +919,13 @@ int Dir_iterNext(JSOBJ _obj, JSONTypeContext *tc) {
925
919
continue ;
926
920
}
927
921
928
- GET_TC (tc )-> itemName = itemName ;
922
+ GET_TC (tc )-> itemName = attr ;
929
923
GET_TC (tc )-> itemValue = itemValue ;
930
-
931
- itemName = attr ;
932
- break ;
924
+ GET_TC (tc )-> index ++ ;
925
+ return 1 ;
933
926
}
934
927
935
- if (itemName == NULL ) {
936
- GET_TC (tc )-> index = GET_TC (tc )-> size ;
937
- GET_TC (tc )-> itemValue = NULL ;
938
- return 0 ;
939
- }
940
-
941
- GET_TC (tc )-> itemName = itemName ;
942
- GET_TC (tc )-> itemValue = itemValue ;
943
- GET_TC (tc )-> index ++ ;
944
-
945
- return 1 ;
928
+ return 0 ;
946
929
}
947
930
948
931
JSOBJ Dir_iterGetValue (JSOBJ Py_UNUSED (obj ), JSONTypeContext * tc ) {
0 commit comments