-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Conversation
@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. |
@@ -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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is removed?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this 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.
What's your opinion @mdickinson ? Does it look good to you now? |
No description provided.