11// SPDX-License-Identifier: (Apache-2.0 OR MIT)
22
3- #![ cfg_attr( feature = "intrinsics" , feature( core_intrinsics) ) ]
43#![ cfg_attr( feature = "optimize" , feature( optimize_attribute) ) ]
54#![ cfg_attr( feature = "generic_simd" , feature( portable_simd) ) ]
6- #![ allow ( internal_features ) ] // core_intrinsics
5+ #![ cfg_attr ( feature = "cold_path" , feature ( cold_path ) ) ]
76#![ allow( non_camel_case_types) ]
87#![ allow( stable_features) ] // MSRV
98#![ allow( static_mut_refs) ]
@@ -392,7 +391,8 @@ pub(crate) unsafe extern "C" fn dumps(
392391 let mut optsptr: Option < NonNull < PyObject > > = None ;
393392
394393 let num_args = PyVectorcall_NARGS ( isize_to_usize ( nargs) ) ;
395- if unlikely ! ( num_args == 0 ) {
394+ if num_args == 0 {
395+ cold_path ! ( ) ;
396396 return raise_dumps_exception_fixed (
397397 "dumps() missing 1 required positional argument: 'obj'" ,
398398 ) ;
@@ -403,18 +403,21 @@ pub(crate) unsafe extern "C" fn dumps(
403403 if num_args & 3 == 3 {
404404 optsptr = Some ( NonNull :: new_unchecked ( * args. offset ( 2 ) ) ) ;
405405 }
406- if unlikely ! ( !kwnames. is_null( ) ) {
406+ if !kwnames. is_null ( ) {
407+ cold_path ! ( ) ;
407408 for i in 0 ..=Py_SIZE ( kwnames) . saturating_sub ( 1 ) {
408409 let arg = crate :: ffi:: PyTuple_GET_ITEM ( kwnames, i as Py_ssize_t ) ;
409410 if core:: ptr:: eq ( arg, typeref:: DEFAULT ) {
410- if unlikely ! ( num_args & 2 == 2 ) {
411+ if num_args & 2 == 2 {
412+ cold_path ! ( ) ;
411413 return raise_dumps_exception_fixed (
412414 "dumps() got multiple values for argument: 'default'" ,
413415 ) ;
414416 }
415417 default = Some ( NonNull :: new_unchecked ( * args. offset ( num_args + i) ) ) ;
416418 } else if core:: ptr:: eq ( arg, typeref:: OPTION ) {
417- if unlikely ! ( num_args & 3 == 3 ) {
419+ if num_args & 3 == 3 {
420+ cold_path ! ( ) ;
418421 return raise_dumps_exception_fixed (
419422 "dumps() got multiple values for argument: 'option'" ,
420423 ) ;
@@ -430,14 +433,17 @@ pub(crate) unsafe extern "C" fn dumps(
430433
431434 let mut optsbits: i32 = 0 ;
432435 if let Some ( opts) = optsptr {
436+ cold_path ! ( ) ;
433437 if core:: ptr:: eq ( ( * opts. as_ptr ( ) ) . ob_type , typeref:: INT_TYPE ) {
434438 #[ allow( clippy:: cast_possible_truncation) ]
435439 let tmp = PyLong_AsLong ( optsptr. unwrap ( ) . as_ptr ( ) ) as i32 ; // stmt_expr_attributes
436440 optsbits = tmp;
437- if unlikely ! ( !( 0 ..=opt:: MAX_OPT ) . contains( & optsbits) ) {
441+ if !( 0 ..=opt:: MAX_OPT ) . contains ( & optsbits) {
442+ cold_path ! ( ) ;
438443 return raise_dumps_exception_fixed ( "Invalid opts" ) ;
439444 }
440- } else if unlikely ! ( !core:: ptr:: eq( opts. as_ptr( ) , typeref:: NONE ) ) {
445+ } else if !core:: ptr:: eq ( opts. as_ptr ( ) , typeref:: NONE ) {
446+ cold_path ! ( ) ;
441447 return raise_dumps_exception_fixed ( "Invalid opts" ) ;
442448 }
443449 }
0 commit comments