libdparse icon indicating copy to clipboard operation
libdparse copied to clipboard

make Statement, StatementNoCaseNoDefault and Declaration use SumType

Open WebFreak001 opened this issue 2 years ago • 1 comments

old Declaration code used algebraic, which is more efficiently replaced with sumtype.

I replaced the mixin-generated properties with manual properties, since the code is very small for them anyway and helps them being shown in DCD

Since SumType works with well-defiend types, opEquals and visitIfNotNull was trivial to implement.

Saves around 0-3 MB of actual peak RAM in a ~170 MB test environment (could just be fluctuations how much it actually is, but it will definitely include some RAM savings, since we no longer store a bunch of nulls for common types)

Easy backwards-compatible improvement I think.

Made setters backwards-incompatible on purpose, since we don't want accidental assignment of 2 different types on the same sumtype.

WebFreak001 avatar Mar 22 '23 03:03 WebFreak001

Codecov Report

Merging #489 (7f7a9ce) into master (98bf0f4) will increase coverage by 0.04%. The diff coverage is 82.27%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #489      +/-   ##
==========================================
+ Coverage   83.49%   83.53%   +0.04%     
==========================================
  Files          11       11              
  Lines        8483     8541      +58     
==========================================
+ Hits         7083     7135      +52     
- Misses       1400     1406       +6     
Impacted Files Coverage Δ
src/dparse/ast.d 71.97% <80.82%> (+1.72%) :arrow_up:
src/dparse/parser.d 91.43% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

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

codecov[bot] avatar Mar 22 '23 03:03 codecov[bot]