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

Replace structure() by class() #393

Merged
merged 2 commits into from
Jun 29, 2023

Conversation

mgirlich
Copy link
Contributor

@mgirlich mgirlich commented Jun 1, 2023

This gives a small performance improvement, e.g. for xml_find_all(flatten = TRUE)

library(xml2)

path <- xml2_example("cd_catalog.xml")
xml <- read_xml(path)
cds <- xml_find_all(xml, "CD")

find <- function() {
  xml_find_all(cds, "TITLE", flatten = FALSE)
}

bench::mark(
  find()
)

# Before
#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 find()        400µs    428µs     2165.    30.3KB     10.3

# After
#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 find()        324µs    360µs     2529.    30.3KB     8.20

Created on 2023-06-01 with reprex v2.0.2

This helps towards #394.

@hadley hadley merged commit f251e92 into r-lib:main Jun 29, 2023
@hadley
Copy link
Member

hadley commented Jun 29, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants