gocardless/statesman — pull request #76 by pacso (2014-09-02 06:46:20+00:00)
Title: Avoid repeated SQL lookups for current_state

Currently, assuming you're not using memory for persistence, when `available_events` is called multiple identical SQL lookups for `current_state` will be triggered. With a large transitions table this could cause a noticeable delay in execution.

By caching a copy of the `current_state` in a local variable for the method we can avoid performing this lookup more than once.