Skip to content

memory: correctly merge segments when the new block prepends the old#17

Merged
benedekkupper merged 1 commit intomainfrom
memory-merge
Feb 10, 2026
Merged

memory: correctly merge segments when the new block prepends the old#17
benedekkupper merged 1 commit intomainfrom
memory-merge

Conversation

@benedekkupper
Copy link
Member

Closes #15

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes segment merging in RawMemory.TryAddSegment when the incoming segment should merge contiguously with an existing segment (specifically the “prepend” case from Issue #15).

Changes:

  • Replace Segment.TryAppend with Segment.TryMerge to support merging in both directions (prepend/append).
  • Update RawMemory.TryAddSegment to use TryMerge when attempting to coalesce contiguous segments.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
DeviceProgramming/Memory/Segment.cs Reworks contiguous-segment combination logic into TryMerge.
DeviceProgramming/Memory/RawMemory.cs Switches add-path merge attempt to call TryMerge on existing segments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@benedekkupper benedekkupper merged commit 37e4335 into main Feb 10, 2026
1 check passed
@benedekkupper benedekkupper deleted the memory-merge branch February 10, 2026 22:31
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.

RawMemory.TryAddSegment fails, when the new segment is prepended to an existing segment

2 participants