Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove incorrect assertion in MarkedCircularBuffer.popFirst #1627

Merged
merged 2 commits into from Sep 3, 2020

Conversation

glbrntt
Copy link
Contributor

@glbrntt glbrntt commented Sep 2, 2020

Motivation:

MarkedCircularBuffer.popFirst() asserts that the backing buffer should
contain more than zero elements yet popFirst() allows nil to be
returned when there is no value to return.

Modifications:

  • Move the assertion from popFirst() -> Element? to removeFirst() -> Element
  • Test for popFirst()

Result:

  • We can safely call popFirst() on an empty MarkedCircularBuffer in
    debug mode.

Motivation:

`MarkedCircularBuffer.popFirst()` asserts that the backing buffer should
contain more than zero elements yet `popFirst()` allows `nil` to be
returned when there is no value to return.

Modifications:

- Move the assertion from `popFirst() -> Element?` to `removeFirst() -> Element`
- Test for `popFirst()`

Result:

- We can safely call `popFirst()` on an empty `MarkedCircularBuffer` in
  debug mode.
@glbrntt glbrntt added the patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1) label Sep 2, 2020
Copy link
Contributor

@Davidde94 Davidde94 left a comment

Choose a reason for hiding this comment

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

LGTM

@glbrntt glbrntt merged commit 98721c7 into apple:master Sep 3, 2020
@glbrntt glbrntt deleted the gb-marked-circular-buffer-pop-first branch September 3, 2020 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch-version-bump-only For PRs that when merged will only cause a bump of the patch version, ie. 1.0.x -> 1.0.(x+1)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants