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.
This PR aims to fix #5730.
Briefly, using the
.data
pronoun caused the plot to slow down by a non-trivial amount of time. This PR rectifies this by considering the pronoun as 'non-data'. To explain a bit further, here follows the diagnosis.unrowname()
throws errors with pronouns:Created on 2024-02-29 with reprex v2.1.0
And
unrowname()
is used to compare to see if a part of an expression evaluates to the plot data here:ggplot2/R/aes.R
Lines 437 to 440 in bc3e401
As this is in a
tryCatch()
block, the errors thatunrowname()
throws for pronouns are silenced. However, formatting the error message is still relatively expensive.In this PR, we circumvent this problem by recognising that the
.data
pronoun is not the same as the regular plot data, thereby bypassing the check in the lines above.As a benchmark, we see that typical evaluation and with pronoun are in the same range with this PR:
Created on 2024-02-29 with reprex v2.1.0
For reference, this is the same benchmark result, but on the current main branch: