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

RedBlackTree.empty: const, .front/.back: inout #7644

Merged
merged 2 commits into from
Sep 30, 2020

Conversation

SimonN
Copy link
Contributor

@SimonN SimonN commented Sep 27, 2020

In RedBlackTree, add all possible qualifiers const pure nothrow @safe @nogc to empty() and length(). The class is final, thus I assume that this agrees with any user code.

Add the single qualifier inout to front() and back().

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @SimonN! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#7644"

@Geod24
Copy link
Member

Geod24 commented Sep 28, 2020

The class is also templated so some changes are superfluous. The const and inout additions are good though.

@SimonN
Copy link
Contributor Author

SimonN commented Sep 28, 2020

Thanks! Right, my user code will need only const and inout.

Tonight, I'll add a unittest to this PR that calls into empty and length from a const pure nothrow @safe @nogc context, and remove all qualifiers from empty and length that are auto-inferred -- which I think will be all four of pure nothrow @safe @nogc.

@SimonN SimonN marked this pull request as draft September 28, 2020 05:42
@SimonN SimonN changed the title RedBlackTree.empty/.length: const etc.; .front/.back: inout RedBlackTree.empty: const, .front/.back: inout Sep 28, 2020
@SimonN
Copy link
Contributor Author

SimonN commented Sep 28, 2020

Now, I annotate only with const and inout. I test explicitly that empty() and length() still qualify as const pure nothrow @safe @nogc.

Already before this PR, length() had the single necessary qualifier const. Therefore this PR modifies only empty(), front(), and back().

@SimonN SimonN marked this pull request as ready for review September 28, 2020 20:03
@SimonN SimonN marked this pull request as draft September 28, 2020 21:25
RedBlackTree is a template, therefore all other qualifiers
for empty(), length(), and opBinaryRight!"in" will be inferred:
pure, nothrow, @safe, @nogc.
@SimonN
Copy link
Contributor Author

SimonN commented Sep 29, 2020

The unittest for all attributes is now part of the existing constness unittest.

I test all three of empty, length, and opBinaryRight"in" for const pure nothrow @safe @nogc and separately for immutable.

Reviewers: Requiring all qualifiers to be inferred for opBinaryRight!"in" is potentially up for debate. It's a search in a sorted tree for at most a single element, though, and thus not expected to allocate.

@SimonN SimonN marked this pull request as ready for review September 29, 2020 06:57
@thewilsonator thewilsonator merged commit b0b64c3 into dlang:master Sep 30, 2020
@SimonN
Copy link
Contributor Author

SimonN commented Sep 30, 2020

Thanks for the quick review and merge!

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.

4 participants