Skip to content

Memoize the value of show_exceptions?#46609

Closed
skipkayhil wants to merge 2 commits intorails:mainfrom
skipkayhil:memoize-show-exceptions
Closed

Memoize the value of show_exceptions?#46609
skipkayhil wants to merge 2 commits intorails:mainfrom
skipkayhil:memoize-show-exceptions

Conversation

@skipkayhil
Copy link
Copy Markdown
Member

Motivation / Background

Previously, the value of action_dispatch.show_exceptions would be compared with false every time show_exceptions? is called. As described in the previous comment, the purpose of the comparison is to treat a nil configuration as true.

Detail

This commit does what the rest of the comment suggests, which is to move the comparison into env_config so that show_exceptions? just looks up the value stored in env and doesn't have to do any comparisons.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.
  • CI is passing.

Previously, the value of `action_dispatch.show_exceptions` would be
compared with `false` every time `show_exceptions?` is called. As
described in the previous comment, the purpose of the comparison is to
treat a `nil` configuration as `true`.

This commit does what the rest of the comment suggests, which is to move
the comparison into `env_config` so that `show_exceptions?` just looks
up the value stored in `env` and doesn't have to do any comparisons.
@matthewd
Copy link
Copy Markdown
Member

(I wouldn't really characterize this change as memoizing, but) it looks like this changes the behaviour where the middleware is included directly, outside of a Rails::Application.

This doesn't pass a bunch of tests because they rely on being able to
set the value dynamically. I wonder if that makes this worth keeping?
@skipkayhil
Copy link
Copy Markdown
Member Author

Closing for now as this won't really work as is, mostly just pushing up my idea so I don't lose it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants