I think that is a bad solution, or no solution at all.

After this change…

The attachment still will be created as new entries in the posts and postmeta tables in the WordPress database
From now, the user hasn’t any setting to decide to use or not to use the attachments URLs, it’s needed to modify the option in the DB or in the admin options.php hidden page

In regard to performance is a mistake. The problem remains, and hidden to the user.

So, for the end user was a better approach to use SEO plugins settings, where it can be decided how the attachment pages are to be showed, or not.