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

perf: add missing fixed for fixed strings #728

Merged
merged 1 commit into from
Oct 3, 2024
Merged

Conversation

m-muecke
Copy link
Contributor

@m-muecke m-muecke commented Oct 3, 2024

  • Add fixed for fixed strings
  • Replace any(is.na(x)) with anyNA(x)

@gaborcsardi
Copy link
Member

gaborcsardi commented Oct 3, 2024

Thanks! Interestingly the difference is not very big:

x <- cli:::lorem_ipsum()
❯ bench::mark(regex = strsplit(x, ""), fixed = strsplit(x, "", fixed = TRUE))
# A tibble: 2 × 13
  expression      min median `itr/sec` mem_alloc `gc/sec` n_itr  n_gc total_time
  <bch:expr> <bch:tm> <bch:>     <dbl> <bch:byt>    <dbl> <int> <dbl>   <bch:tm>
1 regex        5.86µs 7.34µs   120600.    3.46KB      0   10000     0     82.9ms
2 fixed         5.9µs 6.15µs   156167.    3.46KB     15.6  9999     1       64ms
# ℹ 4 more variables: result <list>, memory <list>, time <list>, gc <list>

@gaborcsardi gaborcsardi merged commit fbec918 into r-lib:main Oct 3, 2024
13 checks passed
@gaborcsardi
Copy link
Member

Thanks!

@m-muecke m-muecke deleted the fixed branch October 3, 2024 20:12
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