8000 MAINT: Removed conditionals that are always false in datetime_strings.c by kawochen · Pull Request #7102 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Removed conditionals that are always false in datetime_strings.c #7102

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

Merged
merged 1 commit into from
Jan 29, 2016

Conversation

kawochen
Copy link
Contributor

These conditionals always evaluate to 0.

@jaimefrio
Copy link
Member

Can you ellaborate on why negative values are not possible?

@@ -484,7 +484,7 @@ parse_iso_8601_datetime(char *str, Py_ssize_t len,
if (sublen >= 2 && isdigit(substr[0]) && isdigit(substr[1])) {
out->hour = 10 * (substr[0] - '0') + (substr[1] - '0');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

substr[0] and substr[1] are char digits (isdigit), of which '0' is the smallest, so out->hour can only be as small as 10 * 0 + 0 = 0

@kawochen kawochen changed the title MAINT: Removed conditionals that are always true in datetime_strings.c MAINT: Removed conditionals that are always false in datetime_strings.c Jan 26, 2016
@charris
Copy link
Member
charris commented Jan 26, 2016

LGTM. One of the fixes looks like it also fixes a cut and paste error.

charris added a commit that referenced this pull request Jan 29, 2016
MAINT: Removed conditionals that are always false in datetime_strings.c
@charris charris merged commit 7a46e39 into numpy:master Jan 29, 2016
@charris
Copy link
Member
charris commented Jan 29, 2016

Thanks @kawochen .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0