Have you actually *tested* this to see how much it slows down your site? I don't think you know what is fast and what is slow.
BTW in the example above (applying to all links) you can use str_replace instead of preg_replace which would be faster. But all of this is just milliseconds improvement.