dissect.cstruct icon indicating copy to clipboard operation
dissect.cstruct copied to clipboard

Save space saving sizes of dynamic fields only

Open twiggler opened this issue 7 months ago • 1 comments

Currently, actual sizes of all fields are stored inside the _sizes private member. This can cause high memory usage in some applications.

This PR only stores the sizes of dynamic fields. Since most fields are static, we significantly reduce memory usage, utilities like dumpstruct still work as intended.

Alternative solution considered: Remove _sizes completely. However, no alternative way has been found to reconstruct the number of bytes read. This would result in loss of the pretty colors in dump_struct, for example

twiggler avatar May 19 '25 07:05 twiggler

Codecov Report

Attention: Patch coverage is 86.88525% with 8 lines in your changes missing coverage. Please review.

Project coverage is 92.17%. Comparing base (e990b53) to head (dc39c7b).

Files with missing lines Patch % Lines
dissect/cstruct/types/structure.py 88.63% 5 Missing :warning:
dissect/cstruct/parser.py 57.14% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #122      +/-   ##
==========================================
- Coverage   92.24%   92.17%   -0.07%     
==========================================
  Files          21       21              
  Lines        2477     2506      +29     
==========================================
+ Hits         2285     2310      +25     
- Misses        192      196       +4     
Flag Coverage Δ
unittests 92.17% <86.88%> (-0.07%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar May 19 '25 07:05 codecov[bot]

Could this change be documented, e.g. using a CHANGELOG file entry?

JSCU-CNI avatar Jun 18 '25 09:06 JSCU-CNI