perf: skip unnecessary main data read in _lx_nand_flash_sector_read #65
+22
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue
Fixes #64
Problem Description
The
_lx_nand_flash_sector_readfunction currently reads both main data area and spare data area when matching logical sector numbers. This is unnecessary since only spare area data is needed for sector matching, resulting in severe performance degradation.Solution
This PR optimizes the sector read logic to:
Implementation Details
Modified function:
_lx_nand_flash_sector_readKey changes:
Driver requirement:
NAND flash drivers must check if the main data area pointer is NULL and skip reading the main data area in that case.
Performance Results
Tested on W25N01GV NAND Flash with LevelX + FileX stack:
Summary:
Testing
Breaking Changes
None. This is a pure performance optimization that maintains backward compatibility.
Additional Notes
This optimization is especially important for read-intensive applications. The 3.5x read performance improvement significantly enhances user experience.