Change regex usage to manual parsing #1094
Merged
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.
I started profiling the "worst case" of evaluating formulas which seemed to take a lot of resources. The culprit turned out to be usage of regex parsing to get column/row/cell information. I created a custom parser that should fulfill the current needs and is a lot faster as it's being called in hot code paths. I also updated APIs to allow also
ReadOnlySpan<char>
for operations that needed substring to work with.Based on running the benchmarks in the other PR, here are the improvement numbers. Still room to improve but this was the low-hanging fruit as first step.
NPOI.Benchmarks.LargeExcelFileBenchmark
NPOI.Benchmarks.RangeValuesBenchmark