@@ -1817,33 +1817,41 @@ unsafe extern "C" fn uuid_init_vectorcall(
18171817 }
18181818}
18191819
1820+ enum UnarySelfResult {
1821+ SelfObject ( * mut PyObject ) ,
1822+ OriginalResult ( * mut PyObject ) ,
1823+ }
1824+
1825+ #[ inline( always) ]
18201826unsafe fn unary_self (
18211827 callable : * mut PyObject ,
18221828 args : * const * mut PyObject ,
18231829 nargsf : usize ,
18241830 kwnames : * mut PyObject ,
1825- ) -> Option < * mut PyObject > {
1831+ ) -> Option < UnarySelfResult > {
18261832 unsafe {
18271833 if PyVectorcall_NARGS ( nargsf) != 1 || keyword_count ( kwnames) != 0 {
1828- call_original ( callable, args, nargsf, kwnames) ;
1829- return None ;
1834+ return Some ( UnarySelfResult :: OriginalResult ( call_original (
1835+ callable, args, nargsf, kwnames,
1836+ ) ) ) ;
18301837 }
18311838
18321839 let self_object = * args;
18331840 if ( * self_object) . ob_type == UUID_TYPE . cast :: < PyTypeObject > ( ) {
1834- return Some ( self_object) ;
1841+ return Some ( UnarySelfResult :: SelfObject ( self_object) ) ;
18351842 }
18361843
18371844 let instance_check = PyObject_IsInstance ( self_object, UUID_TYPE ) ;
18381845 if instance_check < 0 {
18391846 return None ;
18401847 }
18411848 if instance_check == 0 {
1842- call_original ( callable, args, nargsf, kwnames) ;
1843- return None ;
1849+ return Some ( UnarySelfResult :: OriginalResult ( call_original (
1850+ callable, args, nargsf, kwnames,
1851+ ) ) ) ;
18441852 }
18451853
1846- Some ( self_object)
1854+ Some ( UnarySelfResult :: SelfObject ( self_object) )
18471855 }
18481856}
18491857
@@ -1854,8 +1862,10 @@ unsafe extern "C" fn uuid_str_vectorcall(
18541862 kwnames : * mut PyObject ,
18551863) -> * mut PyObject {
18561864 unsafe {
1857- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
1858- return ptr:: null_mut ( ) ;
1865+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
1866+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
1867+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
1868+ None => return ptr:: null_mut ( ) ,
18591869 } ;
18601870 let Some ( value) = uuid_int ( self_object) else {
18611871 return call_original ( callable, args, nargsf, kwnames) ;
@@ -1871,8 +1881,10 @@ unsafe extern "C" fn uuid_hex_vectorcall(
18711881 kwnames : * mut PyObject ,
18721882) -> * mut PyObject {
18731883 unsafe {
1874- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
1875- return ptr:: null_mut ( ) ;
1884+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
1885+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
1886+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
1887+ None => return ptr:: null_mut ( ) ,
18761888 } ;
18771889 let Some ( value) = uuid_int ( self_object) else {
18781890 return call_original ( callable, args, nargsf, kwnames) ;
@@ -1888,8 +1900,10 @@ unsafe extern "C" fn uuid_repr_vectorcall(
18881900 kwnames : * mut PyObject ,
18891901) -> * mut PyObject {
18901902 unsafe {
1891- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
1892- return ptr:: null_mut ( ) ;
1903+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
1904+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
1905+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
1906+ None => return ptr:: null_mut ( ) ,
18931907 } ;
18941908 let class = PyObject_Type ( self_object) ;
18951909 if class. is_null ( ) {
@@ -1919,8 +1933,10 @@ unsafe extern "C" fn uuid_int_method_vectorcall(
19191933 kwnames : * mut PyObject ,
19201934) -> * mut PyObject {
19211935 unsafe {
1922- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
1923- return ptr:: null_mut ( ) ;
1936+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
1937+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
1938+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
1939+ None => return ptr:: null_mut ( ) ,
19241940 } ;
19251941 let int_object = slot_object ( self_object, INT_SLOT_OFFSET ) ;
19261942 if int_object. is_null ( ) {
@@ -1938,8 +1954,10 @@ unsafe extern "C" fn uuid_hash_method_vectorcall(
19381954 kwnames : * mut PyObject ,
19391955) -> * mut PyObject {
19401956 unsafe {
1941- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
1942- return ptr:: null_mut ( ) ;
1957+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
1958+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
1959+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
1960+ None => return ptr:: null_mut ( ) ,
19431961 } ;
19441962 let int_object = slot_object ( self_object, INT_SLOT_OFFSET ) ;
19451963 if int_object. is_null ( ) {
@@ -2132,8 +2150,10 @@ unsafe extern "C" fn uuid_bytes_vectorcall(
21322150 kwnames : * mut PyObject ,
21332151) -> * mut PyObject {
21342152 unsafe {
2135- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
2136- return ptr:: null_mut ( ) ;
2153+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
2154+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
2155+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
2156+ None => return ptr:: null_mut ( ) ,
21372157 } ;
21382158 let Some ( value) = uuid_int ( self_object) else {
21392159 return call_original ( callable, args, nargsf, kwnames) ;
@@ -2149,8 +2169,10 @@ unsafe extern "C" fn uuid_bytes_le_vectorcall(
21492169 kwnames : * mut PyObject ,
21502170) -> * mut PyObject {
21512171 unsafe {
2152- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
2153- return ptr:: null_mut ( ) ;
2172+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
2173+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
2174+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
2175+ None => return ptr:: null_mut ( ) ,
21542176 } ;
21552177 let Some ( value) = uuid_int ( self_object) else {
21562178 return call_original ( callable, args, nargsf, kwnames) ;
@@ -2166,8 +2188,10 @@ unsafe extern "C" fn uuid_fields_vectorcall(
21662188 kwnames : * mut PyObject ,
21672189) -> * mut PyObject {
21682190 unsafe {
2169- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
2170- return ptr:: null_mut ( ) ;
2191+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
2192+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
2193+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
2194+ None => return ptr:: null_mut ( ) ,
21712195 } ;
21722196 let Some ( value) = uuid_int ( self_object) else {
21732197 return call_original ( callable, args, nargsf, kwnames) ;
@@ -2183,8 +2207,10 @@ unsafe extern "C" fn uuid_field_value_vectorcall<const FIELD: u8>(
21832207 kwnames : * mut PyObject ,
21842208) -> * mut PyObject {
21852209 unsafe {
2186- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
2187- return ptr:: null_mut ( ) ;
2210+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
2211+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
2212+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
2213+ None => return ptr:: null_mut ( ) ,
21882214 } ;
21892215 let Some ( value) = uuid_int ( self_object) else {
21902216 return call_original ( callable, args, nargsf, kwnames) ;
@@ -2274,8 +2300,10 @@ unsafe extern "C" fn uuid_urn_vectorcall(
22742300 kwnames : * mut PyObject ,
22752301) -> * mut PyObject {
22762302 unsafe {
2277- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
2278- return ptr:: null_mut ( ) ;
2303+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
2304+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
2305+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
2306+ None => return ptr:: null_mut ( ) ,
22792307 } ;
22802308 let Some ( value) = uuid_int ( self_object) else {
22812309 return call_original ( callable, args, nargsf, kwnames) ;
@@ -2291,8 +2319,10 @@ unsafe extern "C" fn uuid_variant_vectorcall(
22912319 kwnames : * mut PyObject ,
22922320) -> * mut PyObject {
22932321 unsafe {
2294- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
2295- return ptr:: null_mut ( ) ;
2322+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
2323+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
2324+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
2325+ None => return ptr:: null_mut ( ) ,
22962326 } ;
22972327 let Some ( value) = uuid_int ( self_object) else {
22982328 return call_original ( callable, args, nargsf, kwnames) ;
@@ -2317,8 +2347,10 @@ unsafe extern "C" fn uuid_version_vectorcall(
23172347 kwnames : * mut PyObject ,
23182348) -> * mut PyObject {
23192349 unsafe {
2320- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
2321- return ptr:: null_mut ( ) ;
2350+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
2351+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
2352+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
2353+ None => return ptr:: null_mut ( ) ,
23222354 } ;
23232355 let Some ( value) = uuid_int ( self_object) else {
23242356 return call_original ( callable, args, nargsf, kwnames) ;
@@ -2338,8 +2370,10 @@ unsafe extern "C" fn uuid_getstate_vectorcall(
23382370 kwnames : * mut PyObject ,
23392371) -> * mut PyObject {
23402372 unsafe {
2341- let Some ( self_object) = unary_self ( callable, args, nargsf, kwnames) else {
2342- return ptr:: null_mut ( ) ;
2373+ let self_object = match unary_self ( callable, args, nargsf, kwnames) {
2374+ Some ( UnarySelfResult :: SelfObject ( self_object) ) => self_object,
2375+ Some ( UnarySelfResult :: OriginalResult ( result) ) => return result,
2376+ None => return ptr:: null_mut ( ) ,
23432377 } ;
23442378 let int_object = slot_object ( self_object, INT_SLOT_OFFSET ) ;
23452379 let is_safe = slot_object ( self_object, IS_SAFE_SLOT_OFFSET ) ;
0 commit comments