Description
Replace the current [Polynomial] lookup table with Swift 6.2's InlineArray<256, Polynomial> for better performance and memory layout.
Background
The CRC lookup table currently uses a regular Swift Array with 256 elements. Swift 6.2 introduces InlineArray which provides better performance characteristics for fixed-size arrays by storing elements inline rather than on the heap.
TODO Comment Reference
There's already a TODO comment in the code at line 196-197 in CyclicRedundancyCheck.swift:
// TODO: Replace with InlineArray<256> down the line
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0453-vector.md
Implementation Requirements
- Add conditional compilation to use
InlineArray<256, Polynomial> when Swift 6.2+ is available
- Fall back to regular
Array<Polynomial> for backward compatibility
- Update
Package.swift to enable the experimental InlineArray feature
- Ensure all tests continue to pass
- Verify performance improvements
Considerations
- InlineArray is currently experimental and may require specific Swift toolchain versions
- Need to maintain backward compatibility with older Swift versions
- Should verify the feature is actually available at compile time before using it
Expected Benefits
- Improved cache locality for lookup table access
- Reduced memory allocation overhead
- Better performance for CRC calculations
References
Description
Replace the current
[Polynomial]lookup table with Swift 6.2'sInlineArray<256, Polynomial>for better performance and memory layout.Background
The CRC lookup table currently uses a regular Swift Array with 256 elements. Swift 6.2 introduces
InlineArraywhich provides better performance characteristics for fixed-size arrays by storing elements inline rather than on the heap.TODO Comment Reference
There's already a TODO comment in the code at line 196-197 in
CyclicRedundancyCheck.swift:Implementation Requirements
InlineArray<256, Polynomial>when Swift 6.2+ is availableArray<Polynomial>for backward compatibilityPackage.swiftto enable the experimental InlineArray featureConsiderations
Expected Benefits
References