Pad array writes to the correct number of entries#166
Conversation
Merging this PR will improve performance by 11.64%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_benchmark_getattr_types |
12.1 µs | 10.8 µs | +12.49% |
| ⚡ | test_benchmark_getattr_constants |
11.9 µs | 10.8 µs | +10.79% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix-array-write (29ceaaa) with main (8fd1506)
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #154 by ensuring fixed-size array fields (especially trailing arrays in structs) serialize to the full declared size by padding missing entries, and by erroring when writes exceed the declared static size.
Changes:
- Pad static arrays on write when fewer than
num_entrieselements/characters are provided (base arrays,char[],wchar[]), while raisingArraySizeErroron overflow. - Add/extend tests to validate correct padding behavior and overflow errors for
uint8[],char[], andwchar[]. - Fix a spelling typo in structure field-offset comments (“alligned” → “aligned”).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_types_wchar.py | Adds regression tests for wchar[] padding and overflow behavior, including struct end-of-struct array cases. |
| tests/test_types_char.py | Adds regression tests for char[] padding and overflow behavior, including struct end-of-struct array cases. |
| tests/test_types_base.py | Adds regression tests for generic array padding on write (primitive and struct element arrays). |
| dissect/cstruct/types/wchar.py | Pads static wchar[] writes to num_entries, raising ArraySizeError on overflow. |
| dissect/cstruct/types/char.py | Pads static char[] writes to num_entries, raising ArraySizeError on overflow; broadens _write input types. |
| dissect/cstruct/types/base.py | Pads static generic arrays to num_entries using element defaults, raising ArraySizeError on overflow. |
| dissect/cstruct/types/structure.py | Comment spelling correction only. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
10001c1 to
da7d372
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #166 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 22 22
Lines 2773 2785 +12
=====================================
- Misses 2773 2785 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
da7d372 to
d79403a
Compare
d79403a to
29ceaaa
Compare
Fixes #154