Improve speed using stringi package #440
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an incomplete PR for feedback before I continue with it. It replaces a number of calls to
paste0()
andpaste()
withstringi::stri_join()
, which is approximately 4x faster.This came up in a project of mine where I needed to write a create a large number of styles and apply them to a large number of cells (in many workbooks!). We found a speed bottleneck in the
paste()
functions at https://github.com/awalker89/openxlsx/blob/master/R/WorkbookClass.R#L2105-L2106 , so these changes helped speed up the process and my team is using this fork.If you are interested in this PR, I'd be happy to go through the rest of the package and replace calls (
paste()
,gsub()
,grepl()
, date formatting, etc.) that could be accelerated with their stringi equivalents, which in my experience are 2-4x faster.stringi is a mixed bag as a dependency - it takes a while to install from source because it contains all of unicode, but it has no non-base dependencies and many people have it already as it is a tidyverse dependency. In my experience it is also quite stable.