Repository navigation
Use node-level | for efficiency in infix_spaces_linter - #2025
Conversation
|
I started a Wiki page here: My first thought was to add notes like this or an efficiency/"advanced" section to the custom_linters vignette, but I think a Wiki may be preferable here for reasons noted there. |
|
The |
|
how about //OP[parent::expr[count(expr) >2]] untested but hopefully it's clear what I mean -- test against unary operator on parent instead of self |
|
Worth a try. |
|
Not quite so simple (h/t our extensive test suite!), but the basic idea works. The complications for future reference were:
|
| ({xp_or(paste0('self::', infix_tokens))}) | ||
| and position() > 1 | ||
| xpath <- paste(collapse = "|", glue::glue("//{infix_tokens}[ | ||
| parent::*[count(expr) + count(SYMBOL_SUB) > 1] |
There was a problem hiding this comment.
is count(expr | SYMBOL_SUB) a thing?
There was a problem hiding this comment.
Nice! I still don't have a good sense of when | can be used like this. It passed tests locally, so let's go for it!
Codecov Report
@@ Coverage Diff @@
## main #2025 +/- ##
==========================================
- Coverage 98.55% 98.55% -0.01%
==========================================
Files 113 113
Lines 4995 4994 -1
==========================================
- Hits 4923 4922 -1
Misses 72 72
|
|
Do we have a test for something like |
Similar to #2024, I found
infix_spaces_linter()to be among the slowest, and apparently owing to the//*expression.It's really slow! Even with 22 entries in
//NODE1[...] | //NODE2[...] | ... | //NODE22[...], I find this approach about 3x as fast in the core loop: