Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid early materialization of ALTREP objects #4210

Merged
merged 2 commits into from Jan 23, 2019
Merged

Conversation

@jmcphers
Copy link
Member

@jmcphers jmcphers commented Jan 23, 2019

Currently, ALTREP objects (new in R 3.5.0) are fully materialized by RStudio's environment pane, since it calls object.size() on them. This change protects these objects from premature evaluation by avoiding the environment pane's size/length inspection on objects with the alt flag set (indicating an ALTREP).

Note that this does not protect the objects from any type of materialization at all; the first few elements will still be materialized by str(), which we continue to call.

Fixes #4171.

@jmcphers jmcphers requested a review from kevinushey Jan 23, 2019
@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Jan 23, 2019

LGTM!

Do we need any UI-side changes so that the Environment pane reports something reasonable for these objects (when in Grid view)?

public:
bool empty() const { return versionMajor_ != 0; }
bool empty() const { return versionMajor_ == 0; }
Copy link
Contributor

@kevinushey kevinushey Jan 23, 2019

Yikes! I guess we weren't ever really exercising this code path before?

Copy link
Member Author

@jmcphers jmcphers Jan 23, 2019

We were not! As far as I can tell this method was never used before.

@jmcphers
Copy link
Member Author

@jmcphers jmcphers commented Jan 23, 2019

Do we need any UI-side changes so that the Environment pane reports something reasonable for these objects (when in Grid view)?

We just report them as having no size -- the same thing we do for other "don't touch" objects (active bindings, uneval'ed promises, etc.)

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Jan 23, 2019

Gotcha. I think that's fine.

@jmcphers jmcphers merged commit 2cb57d8 into master Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants