Memoize falsy values #30
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ruby treats
nil
andfalse
the same when they're on the left hand side of a||=
. There are a couple of slow bits of code that are supposed to run once, but could run on each call, if they returnnil
orfalse
. This branch changes them to be more explicit about how they handle their instance variables to ensure that the falsy results don't lead to a retry on the next call.#dns
- This can be an array of results ornil
. Before this branch,@dns == nil
initially and if the dns results should benil
. This branch changes the latter case to set@dns = false
, and it checks explicitly for@dns.nil?
to know if it should actually look up any values.#served_by_pages?
- This will returntrue
orfalse
. Before this branch,@served_by_pages
would benil
on init and a boolean after the check had been run. The check ran any time@served_by_pages
wasnil
orfalse
. This branch changes it so that the check only runs when@served_by_pages.nil?
.cc @benbalter