@@ -3940,9 +3940,6 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
3940
3940
if (_Pickler_OpcodeBoundary (self ) < 0 )
3941
3941
return -1 ;
3942
3942
3943
- if (Py_EnterRecursiveCall (" while pickling an object" ))
3944
- return -1 ;
3945
-
3946
3943
/* The extra pers_save argument is necessary to avoid calling save_pers()
3947
3944
on its returned object. */
3948
3945
if (!pers_save && self -> pers_func ) {
@@ -3952,7 +3949,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
3952
3949
1 if a persistent id was saved.
3953
3950
*/
3954
3951
if ((status = save_pers (self , obj )) != 0 )
3955
- goto done ;
3952
+ return status ;
3956
3953
}
3957
3954
3958
3955
type = Py_TYPE (obj );
@@ -3965,40 +3962,39 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
3965
3962
/* Atom types; these aren't memoized, so don't check the memo. */
3966
3963
3967
3964
if (obj == Py_None ) {
3968
- status = save_none (self , obj );
3969
- goto done ;
3965
+ return save_none (self , obj );
3970
3966
}
3971
3967
else if (obj == Py_False || obj == Py_True ) {
3972
- status = save_bool (self , obj );
3973
- goto done ;
3968
+ return save_bool (self , obj );
3974
3969
}
3975
3970
else if (type == & PyLong_Type ) {
3976
- status = save_long (self , obj );
3977
- goto done ;
3971
+ return save_long (self , obj );
3978
3972
}
3979
3973
else if (type == & PyFloat_Type ) {
3980
- status = save_float (self , obj );
3981
- goto done ;
3974
+ return save_float (self , obj );
3982
3975
}
3983
3976
3984
3977
/* Check the memo to see if it has the object. If so, generate
3985
3978
a GET (or BINGET) opcode, instead of pickling the object
3986
3979
once again. */
3987
3980
if (PyMemoTable_Get (self -> memo , obj )) {
3988
- if (memo_get (self , obj ) < 0 )
3989
- goto error ;
3990
- goto done ;
3981
+ return memo_get (self , obj );
3991
3982
}
3992
3983
3993
3984
if (type == & PyBytes_Type ) {
3994
- status = save_bytes (self , obj );
3995
- goto done ;
3985
+ return save_bytes (self , obj );
3996
3986
}
3997
3987
else if (type == & PyUnicode_Type ) {
3998
- status = save_unicode (self , obj );
3999
- goto done ;
3988
+ return save_unicode (self , obj );
4000
3989
}
4001
- else if (type == & PyDict_Type ) {
3990
+
3991
+ /* We're only calling Py_EnterRecursiveCall here so that atomic
3992
+ types above are pickled faster. */
3993
+ if (Py_EnterRecursiveCall (" while pickling an object" )) {
3994
+ return -1 ;
3995
+ }
3996
+
3997
+ if (type == & PyDict_Type ) {
4002
3998
status = save_dict (self , obj );
4003
3999
goto done ;
4004
4000
}
0 commit comments