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

bpo-30224: remove outdated checks in struct #1374

Merged
merged 5 commits into from
May 15, 2017

Conversation

zhangyangyu
Copy link
Member

No description provided.

@mention-bot
Copy link

@zhangyangyu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mdickinson, @serhiy-storchaka and @Yhg1s to be potential reviewers.

@zhangyangyu zhangyangyu added the type-feature A feature request or enhancement label May 2, 2017
@@ -1390,8 +1360,6 @@ prepare_s(PyStructObject *self)
num = c - '0';
while ('0' <= (c = *s++) && c <= '9')
num = num*10 + (c - '0');
if (c == '\0')
Copy link
Member

Choose a reason for hiding this comment

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

Why this is removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

IMHO, this part is another round same as the previous round but without checks. So c == '\0' can't be true anyway otherwise the previous round should have failed. Even if it could be true, does simply break the loop a right behaviour?

@@ -1500,7 +1468,7 @@ s_dealloc(PyStructObject *s)
if (s->s_codes != NULL) {
PyMem_FREE(s->s_codes);
}
Py_XDECREF(s->s_format);
Py_DECREF(s->s_format);
Copy link
Member

Choose a reason for hiding this comment

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

There is also Py_XSETREF in Struct___init___impl.

@@ -1390,8 +1360,6 @@ prepare_s(PyStructObject *self)
num = c - '0';
while ('0' <= (c = *s++) && c <= '9')
num = num*10 + (c - '0');
if (c == '\0')
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure that there's no behaviour change here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ditto.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

The patch makes the code cleaner. If there is some benefit from using PyLong_FromLong() instead of PyLong_FromUnsignedLong() it perhaps be better to move this optimization into PyLong_FromUnsignedLong() itself.

@zhangyangyu
Copy link
Member Author

What's your opinion @mdickinson ? Does it look good to you now?

@zhangyangyu zhangyangyu merged commit 96f5028 into python:master May 15, 2017
@zhangyangyu zhangyangyu deleted the struct branch May 15, 2017 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants