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

Issue 13429: make sicmp and icmp @nogc nothrow. #4933

Merged
merged 1 commit into from Dec 8, 2016
Merged

Issue 13429: make sicmp and icmp @nogc nothrow. #4933

merged 1 commit into from Dec 8, 2016

Conversation

skl131313
Copy link
Contributor

No description provided.

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
13429 icmp (and friends) should be @nogc

@@ -6968,18 +6968,22 @@ static assert(Grapheme.sizeof == size_t.sizeof*4);
$(LREF icmp)
$(REF cmp, std,algorithm,comparison)
+/
int sicmp(S1, S2)(S1 str1, S2 str2) if (isSomeString!S1 && isSomeString!S2)
int sicmp(S1, S2)(S1 r1, S2 r2) @nogc nothrow
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't add @nogc nothrow -- someone might want to use this where S1 and S2 can throw / allocate.

* By using $(REF byUTF, std,utf) and its aliases, GC allocations via auto-decoding
* and thrown exceptions can be avoided, making `icmp` `@safe @nogc nothrow pure`.
*/
@safe @nogc nothrow pure unittest
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't remove unittests without a good reason.

Copy link
Contributor Author

@skl131313 skl131313 Dec 6, 2016

Choose a reason for hiding this comment

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

Well the comment should probably have been the only thing removed then. As the above unittest is no @nogc nothrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite -- "foo" isn't the same as "foo".byDchar.

@dhasenan
Copy link
Contributor

dhasenan commented Dec 6, 2016

The main handy thing from this PR is that is makes sicmp work with arbitrary ranges (and makes the code more similar to icmp). It would be handy to have that part in Phobos.

@dhasenan
Copy link
Contributor

dhasenan commented Dec 6, 2016

Looks good. I'd update the description.

{
if (ridx == str2.length)
if(str2.empty)
Copy link
Member

Choose a reason for hiding this comment

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

style issue: please add a space before the (

@@ -6968,18 +6968,22 @@ static assert(Grapheme.sizeof == size_t.sizeof*4);
$(LREF icmp)
$(REF cmp, std,algorithm,comparison)
+/
int sicmp(S1, S2)(S1 str1, S2 str2) if (isSomeString!S1 && isSomeString!S2)
int sicmp(S1, S2)(S1 r1, S2 r2)
if (isForwardRange!S1 && isSomeChar!(ElementEncodingType!S1)
Copy link
Member

Choose a reason for hiding this comment

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

Why require forward ranges? save is never used in this function

Copy link
Member

@JackStouffer JackStouffer left a comment

Choose a reason for hiding this comment

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

Squash your commits, then LGTM

@9il
Copy link
Member

9il commented Dec 6, 2016

Benchmarks please before merge (with LDC)

@9il
Copy link
Member

9il commented Dec 8, 2016

Auto-merge toggled on

@9il 9il merged commit 5c770fb into dlang:master Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants