Skip to content

Parser has no string allocation#187

Merged
axunonb merged 30 commits intoaxuno:version/v3.0from
axunonb:parser-no-string-allocation
Aug 13, 2021
Merged

Parser has no string allocation#187
axunonb merged 30 commits intoaxuno:version/v3.0from
axunonb:parser-no-string-allocation

Conversation

@axunonb
Copy link
Member

@axunonb axunonb commented Aug 13, 2021

  • Reducing GC pressure by avoiding temporary string assignments. Depending on the input string, GC is reduced by 50-80%.
  • ParserSettings: All internal character lists are returned as List<char>.
  • Internal character lists are cached in the parser for better performance
  • Connected modifications
    • New performance tests for Parser
    • Placeholder property Placeholder?.Parent is renamed to Placeholder?ParentPlaceholder to avoid confusion with Format property Format?.Parent.
    • Placeholder has additional internal properties FormatterNameStartindex, FormatterNameLength, FormatterOptionsStartindex and FormatterOptionsLength

axunonb and others added 30 commits April 17, 2021 10:25
@codecov
Copy link

codecov bot commented Aug 13, 2021

Codecov Report

Merging #187 (b0e40a4) into version/v3.0 (dea77a7) will decrease coverage by 0%.
The diff coverage is 99%.

Impacted file tree graph

@@             Coverage Diff             @@
##           version/v3.0   #187   +/-   ##
===========================================
- Coverage            95%    95%   -0%     
===========================================
  Files                49     49           
  Lines              2010   2019    +9     
===========================================
+ Hits               1909   1910    +1     
- Misses              101    109    +8     
Impacted Files Coverage Δ
src/SmartFormat/Core/Parsing/Format.cs 83% <80%> (-<1%) ⬇️
src/SmartFormat/Core/Parsing/Parser.cs 93% <99%> (+<1%) ⬆️
src/SmartFormat/Core/Parsing/FormatItem.cs 61% <100%> (ø)
src/SmartFormat/Core/Parsing/LiteralText.cs 100% <100%> (ø)
src/SmartFormat/Core/Parsing/Placeholder.cs 73% <100%> (-24%) ⬇️
src/SmartFormat/Core/Parsing/Selector.cs 100% <100%> (ø)
src/SmartFormat/Core/Settings/ParserSettings.cs 100% <100%> (ø)
src/SmartFormat/SmartFormatter.cs 97% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dea77a7...b0e40a4. Read the comment docs.

@axunonb axunonb merged commit 4565ef7 into axuno:version/v3.0 Aug 13, 2021
@axunonb axunonb deleted the parser-no-string-allocation branch August 27, 2021 19:38
axunonb added a commit to axunonb/SmartFormat that referenced this pull request Mar 10, 2022
Parser does not allocate any strings

* Reducing GC pressure by avoiding temporary string assignments. Depending on the input string, GC is reduced by 50-80%.
* ParserSettings: All internal character lists are returned as List<char>.
* Internal character lists are cached in the parser for better performance
* Connected modifications
  * New performance tests for Parser
  * Placeholder property Placeholder?.Parent is renamed to Placeholder?ParentPlaceholder to avoid confusion with Format property Format?.Parent.
  * Placeholder has additional internal properties FormatterNameStartindex, FormatterNameLength, FormatterOptionsStartindex and FormatterOptionsLength
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.

1 participant