Skip to content

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Aug 13, 2024

No description provided.

Comment on lines +37 to -46
} else if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
}
else if (c >= 'a' && c <= 'f') {
} else {
ZEND_ASSERT(c >= 'a' && c <= 'f');
return c - 'a' + 10;
}
else {
return -1;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm wondering if we should not just use a bitwise operation to make it unconditionally lower/uppercase so that we don't need to do another if check.

Copy link
Member

Choose a reason for hiding this comment

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

That might be probably more expensive if I understand correct you want to use store (not just load). What you can do is is maybe to get rid of one condition but not sure if it's worth the readability:

if (isdigit(c)) {
	return c - '0';
} else if (c >= 'a') {
	ZEND_ASSERT(c <= 'f');
	return c - 'a' + 10;
} else {
	ZEND_ASSERT(c >= 'A' && c <= 'F');
	return c - 'A' + 10;
}

Comment on lines +37 to -46
} else if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
}
else if (c >= 'a' && c <= 'f') {
} else {
ZEND_ASSERT(c >= 'a' && c <= 'f');
return c - 'a' + 10;
}
else {
return -1;
}
Copy link
Member

Choose a reason for hiding this comment

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

That might be probably more expensive if I understand correct you want to use store (not just load). What you can do is is maybe to get rid of one condition but not sure if it's worth the readability:

if (isdigit(c)) {
	return c - '0';
} else if (c >= 'a') {
	ZEND_ASSERT(c <= 'f');
	return c - 'a' + 10;
} else {
	ZEND_ASSERT(c >= 'A' && c <= 'F');
	return c - 'A' + 10;
}

@Girgias Girgias force-pushed the std-refacto branch 2 times, most recently from 1d542c7 to 74330b9 Compare September 12, 2024 17:11
@Girgias Girgias merged commit ab99161 into php:master Sep 12, 2024
8 of 10 checks passed
@Girgias Girgias deleted the std-refacto branch September 12, 2024 17:13
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.

2 participants