com php-src: There is no need to use memchr() for comparisons in these places.: ext/filter/logical_filters.c
| From: | Martin Jansen | Date: | Sun, 03 Feb 2013 12:23:53 +0000 |
| Subject: | com php-src: There is no need to use memchr() for comparisons in these places.: ext/filter/logical_filters.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-71153@lists.php.net to get a copy of this message | ||
Commit: 0661d03ebaab6cf1eff156a4dd203299d0385ae9
Author: Martin Jansen <martin@divbyzero.net> Fri, 28 Dec 2012 15:20:19 +0100
Parents: 2f334438836f37b82d739b20a4d0f875278e4766
Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0661d03ebaab6cf1eff156a4dd203299d0385ae9
Log:
There is no need to use memchr() for comparisons in these places.
Changed paths:
M ext/filter/logical_filters.c
Diff:
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index 52d948b..fededcf 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -799,12 +799,12 @@ void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
tokens = 3;
length = 4;
separator = '.';
- } else if (17 == input_len && memchr(input + 2, '-', 1)) {
+ } else if (17 == input_len && input[2] == '-') {
/* IEEE 802 format: Six hexadecimal digits separated by hyphens. */
tokens = 6;
length = 2;
separator = '-';
- } else if (17 == input_len && memchr(input + 2, ':', 1)) {
+ } else if (17 == input_len && input[2] == ':') {
/* IEEE 802 format: Six hexadecimal digits separated by colons. */
tokens = 6;
length = 2;
@@ -820,7 +820,7 @@ void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
for (i = 0; i < tokens; i++) {
offset = i * (length + 1);
- if (i < tokens - 1 && !memchr(input + offset + length, separator, 1)) {
+ if (i < tokens - 1 && input[offset + length] != separator) {
/* The current token did not end with e.g. a "." */
RETURN_VALIDATION_FAILED
}