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

tagQuery(): Speed enhancements and consistent tag name order #249

Merged
merged 17 commits into from
May 13, 2021

Conversation

schloerke
Copy link
Collaborator

@schloerke schloerke commented May 10, 2021

(Similar to) before:
Screen Shot 2021-05-13 at 12 02 37 PM

Now:
Screen Shot 2021-05-13 at 12 01 56 PM

  • mget() is MUCH faster than as.list.environment() and shuffling the elements.
  • Also removed usage of setdiff() if favor of wrapper to x[match(x, y, 0L) == 0L] to avoid a call to unique()
  • Adjusted some lapply calls to for-loops to avoid lapply overhead
  • Adjusted some walk calls to for-loops to avoid usage of <<-

R/tag_query.R Outdated Show resolved Hide resolved
R/tag_query.R Outdated Show resolved Hide resolved
@wch
Copy link
Collaborator

wch commented May 12, 2021

I don't know if performance is an issue in this code, but if it is, have you considered using mget()?

e <- new.env()
e$a <- 1
e$b <- 2
e$c <- 3

mget(c("c", "a"), e)
#> $c
#> [1] 3
#> 
#> $a
#> [1] 1

(I don't know if mget() is actually faster though -- it's worth testing)

@schloerke schloerke requested a review from wch May 13, 2021 16:09
R/tag_query.R Outdated Show resolved Hide resolved
R/tag_query.R Outdated Show resolved Hide resolved
R/tag_query.R Outdated Show resolved Hide resolved
R/tag_query.R Outdated Show resolved Hide resolved
R/tag_query.R Show resolved Hide resolved
@schloerke schloerke changed the title tagQuery(): Reorder internal tag names when converting back to tag()s tagQuery(): Speed enhancements and consistent tag name order May 13, 2021
@schloerke schloerke merged commit 2e3571e into master May 13, 2021
@schloerke schloerke deleted the tagQuery_name_order branch May 13, 2021 19:47
schloerke added a commit that referenced this pull request May 13, 2021
* master:
  `tagQuery()`: Speed enhancements and consistent tag name order (#249)
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.

3 participants