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 8055 & 8057 - Fix std.algorithm.move issues #572

Merged
merged 4 commits into from
May 8, 2012
Merged

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented May 7, 2012

Issue 8055 - [Regression 2.059] std.algorithm.move corrupts moved object field
Issue 8057 - std.algorithm.move cannot use for nested struct

@@ -1337,7 +1337,16 @@ void move(T)(ref T source, ref T target)
static if (hasElaborateDestructor!T || hasElaborateCopyConstructor!T)
{
static T empty;
memcpy(&source, &empty, T.sizeof);
static if (T.tupleof[$-1].stringof.length >= "this".length &&
T.tupleof[$-1].stringof[$-4 .. $] == "this")
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about using T.tupleof[$-1].stringof.endsWith("this") ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have completely forgotten about endsWith, it's better.

@9rnsr
Copy link
Contributor Author

9rnsr commented May 8, 2012

Optimized unary move().
Compared with binary one, we can avoid aliasing check and one destructor call.

shoo added a commit that referenced this pull request May 8, 2012
Issue 8055 & 8057 - Fix std.algorithm.move issues
@shoo shoo merged commit 8920389 into dlang:master May 8, 2012
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