Bug 602256 made both paths there do the same thing in some cases so it is probably possible to reduce the duplicate code there, or just replace the whole function with a simpler function.
Dave, you want to take this, or should I?
I probably wouldn't get around to it for a while
Created attachment 535599 [details] [diff] [review] Patch v1 Something like this, perhaps?
Comment on attachment 535599 [details] [diff] [review] Patch v1 Yep, like that.