Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRefactor `ensure` and `try_get_with` #45312
Conversation
rust-highfive
assigned
arielb1
Oct 15, 2017
This comment has been minimized.
This comment has been minimized.
|
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
michaelwoerister
assigned
michaelwoerister
and unassigned
arielb1
Oct 16, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks for the PR, @theotherjimmy! I like the code deduplication. However could you:
|
kennytm
added
the
S-waiting-on-author
label
Oct 16, 2017
This comment has been minimized.
This comment has been minimized.
The argument for privacy makes sense and I'll move it. The reason that I put it where I did, is that it did not need to be duplicated for each query type.
Ah, the hardest problem in computer science: naming. Another commit is on the way with the move and rename. Don't hold your breath, it may be a few hours. |
This comment has been minimized.
This comment has been minimized.
You could try and see if you can make this a free-standing function in |
This comment has been minimized.
This comment has been minimized.
|
Thanks for the tip. I'll give that a try. |
This comment has been minimized.
This comment has been minimized.
|
@michaelwoerister I pushed up a commit that should address your review comments. I also moved the implementation of |
theotherjimmy
force-pushed the
theotherjimmy:refactor-ensure
branch
from
77e7c14
to
b335efc
Oct 16, 2017
This comment has been minimized.
This comment has been minimized.
|
Please excuse the rebase. I forgot to delete the old implementation of |
theotherjimmy
force-pushed the
theotherjimmy:refactor-ensure
branch
from
b335efc
to
229bee3
Oct 16, 2017
kennytm
added
S-waiting-on-review
and removed
S-waiting-on-author
labels
Oct 17, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks @theotherjimmy! I think you've found the right place to put the function. @bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
michaelwoerister
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Oct 17, 2017
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 19, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
theotherjimmy
changed the title
Refactor `ensure` and `try_get_with` into `read_node_index`
Refactor `ensure` and `try_get_with`
Oct 19, 2017
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 20, 2017
This comment has been minimized.
This comment has been minimized.
|
|
theotherjimmy commentedOct 15, 2017
There was a bit of code shared between
try_get_withandensure, after Iadded
ensure. I refactored that shared code into a query-agnostic methodcalled
read_node_index.The new method
read_node_indexwill attempt to find the nodeindex (
DepNodeIndex) of a query. Whenread_node_indexfinds theDepNodeIndex, it marks the current query as a reader of the node it'srequesting the index of.
This is used by
try_get_withandensureas it elides the unimportant (tothem) details of if the query is invalidated by previous changed computation (Red)
or new and if they had to mark the query green. For both
try_get_withandensure, they just need to know if they can lookup the results or have toreevaluate.
@nikomatsakis this is the refactor we discussed in the comment thread of #45228