Skip to content

Reuse memory data blocks in HexWidget to eliminate redundant IO reads - #3652

Draft
andersendsa wants to merge 2 commits into
rizinorg:devfrom
andersendsa:memory-reuse
Draft

Reuse memory data blocks in HexWidget to eliminate redundant IO reads#3652
andersendsa wants to merge 2 commits into
rizinorg:devfrom
andersendsa:memory-reuse

Conversation

@andersendsa

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've updated the documentation with the relevant information (if needed)
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description

  • Modified MemoryData::fetch in src/widgets/HexWidget.h.
  • Avoided redundant Core()->ioRead calls by reusing previously fetched QByteArray blocks.
  • Takes advantage of Qt's implicit sharing for O(1) performance.
  • Resolves the existing // FIXME: reuse data if possible comment.

Test plan (required)
1. Basic Functional Verification (UI/Scrolling):
Build Cutter with this branch and open any moderately sized binary.
Navigate to the Hexdump widget.
Scroll smoothly up and down using the mouse wheel, and also use the scrollbar to jump to different sections (both small contiguous steps and large jumps).
Expected Outcome: The memory values should display correctly without any visual corruption, missing chunks, or crashes. Scrolling should feel smooth and responsive.
2. View Resizing & Cache Edge Cases:
Resize the Hexdump widget window significantly (make it much taller and wider) to trigger variable block length fetches.
Expected Outcome: The widget should correctly fetch and stitch together the new blocks along with the reused blocks without rendering artifacts.
3. Developer/Performance Verification (Optional but recommended to prove the optimization):
Temporarily add qDebug() << "ioRead called"; inside the Core()->ioRead fallback loop in MemoryData::fetch (src/widgets/HexWidget.h).
Scroll one line down in the hex view.
Expected Outcome (Master branch): You will see multiple ioRead called prints equivalent to the entire visible screen's blocks.
Expected Outcome (This PR): You will see zero or only one ioRead called print, proving the partial cache overlap is successfully reusing the existing QByteArray blocks.

Closing issues

andersendsa and others added 2 commits July 28, 2026 13:23
- Modified `MemoryData::fetch` in `src/widgets/HexWidget.h`.
- Avoided redundant `Core()->ioRead` calls by reusing previously fetched QByteArray blocks.
- Takes advantage of Qt's implicit sharing for O(1) performance.
- Resolves the existing `// FIXME: reuse data if possible` comment.
@andersendsa
andersendsa marked this pull request as draft July 28, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant