-
Notifications
You must be signed in to change notification settings - Fork 196
Open
Labels
internalsIssues related to inner workings of lintr, i.e., not user-visibleIssues related to inner workings of lintr, i.e., not user-visibleperformance
Description
If we know the type of the parent node (or don't care about it), parent::* is faster than parent::expr:
Here is comparison data for
x <- get_source_expressions("https://raw.githubusercontent.com/Rdatatable/data.table/master/inst/tests/tests.Rraw")
xml <- x$expressions[[length(x$expressions)]]$full_xml_parsed_contentsystem.time(xml_find_all(xml, "//SYMBOL_FUNCTION_CALL/parent::expr"))
# user system elapsed
# 2.02 0.00 2.02
system.time(xml_find_all(xml, "//SYMBOL_FUNCTION_CALL/parent::expr/parent::expr"))
# user system elapsed
# 3.903 0.000 3.904
system.time(xml_find_all(xml, "//SYMBOL_FUNCTION_CALL/parent::*"))
# user system elapsed
# 1.989 0.000 1.989
system.time(xml_find_all(xml, "//SYMBOL_FUNCTION_CALL/parent::*/parent::*"))
# user system elapsed
# 3.877 0.000 3.877 Originally posted by @AshesITR in #2496 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
internalsIssues related to inner workings of lintr, i.e., not user-visibleIssues related to inner workings of lintr, i.e., not user-visibleperformance