Adding body class when post contains a specific shortcode

I am doing something like this in one of my plugins:

function my_body_class( $c ) {

    global $post;

    if( isset($post->post_content) && has_shortcode( $post->post_content, 'your-shortcode' ) ) {
        $c[] = 'your-class';
    }
    return $c;
}
add_filter( 'body_class', 'my_body_class' );

I’m not sure it was really necessary, but I probably can’t remove it now either. TheDeadMedic is right, you should think about whether you really need to do this.