Skip to content

Split string - avoid allocation of object array. Added StringHelpers.SplitAndTrimTokens#3311

Merged
repo-ranger[bot] merged 2 commits intoNLog:devfrom
snakefoot:SplitAndTrim
Apr 14, 2019
Merged

Split string - avoid allocation of object array. Added StringHelpers.SplitAndTrimTokens#3311
repo-ranger[bot] merged 2 commits intoNLog:devfrom
snakefoot:SplitAndTrim

Conversation

@snakefoot
Copy link
Copy Markdown
Contributor

@snakefoot snakefoot commented Apr 14, 2019

Triggered by #3308 to avoid params-object-array unless needed. But also to encapsulate:

stringValue.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

In a simpler method:

stringValue.SplitAndTrimTokens(';');

That also trims the tokens, and removes empty tokens.


This change is Reviewable

@304NotModified
Copy link
Copy Markdown
Member

👍 c# ext :)

Could you please add some test cases for SplitAndTrimTokens? If that one has a bug, that could have some serious consequences.

@304NotModified 304NotModified changed the title StringHelpers - SplitAndTrimTokens Split string - avoid params-object-array. Added StringHelpers.SplitAndTrimTokens Apr 14, 2019
Comment thread src/NLog/Config/LoggingConfigurationParser.cs
Comment thread src/NLog/Internal/StringHelpers.cs Outdated
Comment thread src/NLog/LayoutRenderers/ExceptionLayoutRenderer.cs
@snakefoot
Copy link
Copy Markdown
Contributor Author

@304NotModified Could you please add some test cases for SplitAndTrimTokens?

Added some unit-tests

Copy link
Copy Markdown
Member

@304NotModified 304NotModified left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@304NotModified 304NotModified added this to the 4.6.3 milestone Apr 14, 2019
@304NotModified 304NotModified changed the title Split string - avoid params-object-array. Added StringHelpers.SplitAndTrimTokens Split string - avoid allocation of object array. Added StringHelpers.SplitAndTrimTokens Apr 14, 2019
@repo-ranger repo-ranger bot merged commit af2ca41 into NLog:dev Apr 14, 2019
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #3311 into dev will decrease coverage by <1%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##             dev   #3311    +/-   ##
======================================
- Coverage     80%     80%   -<1%     
======================================
  Files        356     356            
  Lines      28077   28085     +8     
  Branches    3739    3742     +3     
======================================
- Hits       22495   22489     -6     
- Misses      4503    4517    +14     
  Partials    1079    1079

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants