honeybadger-io/honeybadger-ruby — pull request #34 by nirvdrum (2013-06-19 02:12:28+00:00)
Title: Avoid unnecessary object allocations.

Unfortunately I couldn't get the honeybadger test suite to run, so I wouldn't merge this without verifying it doesn't break anything. But the change itself is pretty innocuous.

Basically, if `context` is called without an argument, the hash shouldn't be created. It's only used for a no-op `merge!` call, so it's really not needed. Yet the object must be created and GC'd and the no-op method must be called. Replacing it with a nil? check incurs negligible overhead in cases where an argument is supplied while reducing object churn.

As an example, this is currently called without an argument as part of the Rack middleware. So every single request to an app ends up creating one of these hashes that it does nothing with.