Skip to content

[Deque/HashTree] Remove references to ManagedBuffer.capacity and use the given minCapacity - #700

Merged
Azoy merged 1 commit into
apple:mainfrom
Azoy:deque-malloc-size
Aug 12, 2026
Merged

[Deque/HashTree] Remove references to ManagedBuffer.capacity and use the given minCapacity#700
Azoy merged 1 commit into
apple:mainfrom
Azoy:deque-malloc-size

Conversation

@Azoy

@Azoy Azoy commented Aug 12, 2026

Copy link
Copy Markdown
Member

When creating a ManagedBuffer object, the factory closure passes the newly created ManagedBuffer instance for the caller to make the header with. Referencing ManagedBuffer.capacity will end up making calls to malloc_size to return the allocation size, but the caller has already supplied it with a minimumCapacity argument. For embedded, it's critical that we don't needlessly link against system symbols that may or may not exist especially since the information we need is already there (and in fact the code was already guarding against it for OpenBSD).

Checklist

  • I've read the Contribution Guidelines
  • My contributions are licensed under the Swift license.
  • I've followed the coding style of the rest of the project.
  • I've added tests covering all new code paths my change adds to the project (if appropriate).
  • I've added benchmarks covering new functionality (if appropriate).
  • I've verified that my change does not break any existing tests or introduce unexplained benchmark regressions.
  • I've updated the documentation if necessary.

@Azoy
Azoy requested a review from lorentey as a code owner August 12, 2026 20:52

@lorentey lorentey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

💯

@Azoy
Azoy force-pushed the deque-malloc-size branch from e3e0241 to 6f6c690 Compare August 12, 2026 21:05
…city

Fix errors

Update Deque._UnsafeHandle.swift
@Azoy
Azoy force-pushed the deque-malloc-size branch from 6f6c690 to d6c0fe0 Compare August 12, 2026 21:09
@Azoy
Azoy merged commit 830f90c into apple:main Aug 12, 2026
75 checks passed
@Azoy
Azoy deleted the deque-malloc-size branch August 12, 2026 22:02
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.

2 participants