diff options
| author | jvoisin | 2018-03-05 14:25:25 +0100 |
|---|---|---|
| committer | jvoisin | 2018-03-05 14:25:25 +0100 |
| commit | 309481168de02f2dee5a4266359d72866442f665 (patch) | |
| tree | ec87f191cb58bcf0dd02bf7478caa9f43b16ddf9 /src | |
| parent | 695f30817ecff47b5a556a79df2ba00fd8fd539e (diff) | |
Improve a bit the performances (+10%)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp_disabled_functions.c | 20 | ||||
| -rw-r--r-- | src/sp_pcre_compat.c | 4 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index 5a39cdf..e279e5f 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -93,8 +93,8 @@ static bool is_local_var_matching( | |||
| 93 | return false; | 93 | return false; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | static const sp_list_node* get_config_node(const char* builtin_name) { | 96 | static inline const sp_list_node* get_config_node(const char* builtin_name) { |
| 97 | if (!builtin_name) { | 97 | if (EXPECTED(!builtin_name)) { |
| 98 | return SNUFFLEUPAGUS_G(config) | 98 | return SNUFFLEUPAGUS_G(config) |
| 99 | .config_disabled_functions->disabled_functions; | 99 | .config_disabled_functions->disabled_functions; |
| 100 | } else if (!strcmp(builtin_name, "eval")) { | 100 | } else if (!strcmp(builtin_name, "eval")) { |
| @@ -217,20 +217,20 @@ bool should_disable(zend_execute_data* execute_data, const char* builtin_name, | |||
| 217 | const char* builtin_param, const char* builtin_param_name) { | 217 | const char* builtin_param, const char* builtin_param_name) { |
| 218 | char current_file_hash[SHA256_SIZE * 2 + 1] = {0}; | 218 | char current_file_hash[SHA256_SIZE * 2 + 1] = {0}; |
| 219 | const sp_list_node* config = get_config_node(builtin_name); | 219 | const sp_list_node* config = get_config_node(builtin_name); |
| 220 | char* complete_path_function = get_complete_function_path(execute_data); | 220 | char* complete_path_function = NULL; |
| 221 | char const* client_ip = getenv("REMOTE_ADDR"); | 221 | const char* current_filename = NULL; |
| 222 | const char* current_filename; | ||
| 223 | 222 | ||
| 224 | if (!config || !config->data) { | 223 | if (!config || !config->data) { |
| 225 | return false; | 224 | return false; |
| 226 | } | 225 | } |
| 227 | 226 | ||
| 228 | if (builtin_name && !strcmp(builtin_name, "eval")) { | 227 | if (UNEXPECTED(builtin_name && !strcmp(builtin_name, "eval"))) { |
| 229 | current_filename = get_eval_filename(zend_get_executed_filename()); | 228 | current_filename = get_eval_filename(zend_get_executed_filename()); |
| 230 | } else { | 229 | } else { |
| 231 | current_filename = zend_get_executed_filename(); | 230 | current_filename = zend_get_executed_filename(); |
| 232 | } | 231 | } |
| 233 | 232 | ||
| 233 | complete_path_function = get_complete_function_path(execute_data); | ||
| 234 | if (!complete_path_function) { | 234 | if (!complete_path_function) { |
| 235 | if (builtin_name) { | 235 | if (builtin_name) { |
| 236 | complete_path_function = estrdup(builtin_name); | 236 | complete_path_function = estrdup(builtin_name); |
| @@ -280,9 +280,11 @@ bool should_disable(zend_execute_data* execute_data, const char* builtin_name, | |||
| 280 | } | 280 | } |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | if (client_ip && config_node->cidr && | 283 | if (config_node->cidr) { |
| 284 | (false == cidr_match(client_ip, config_node->cidr))) { | 284 | char* client_ip = getenv("REMOTE_ADDR"); |
| 285 | goto next; | 285 | if (client_ip && false == cidr_match(client_ip, config_node->cidr)) { |
| 286 | goto next; | ||
| 287 | } | ||
| 286 | } | 288 | } |
| 287 | 289 | ||
| 288 | if (config_node->var) { | 290 | if (config_node->var) { |
diff --git a/src/sp_pcre_compat.c b/src/sp_pcre_compat.c index c3f1d86..795903d 100644 --- a/src/sp_pcre_compat.c +++ b/src/sp_pcre_compat.c | |||
| @@ -22,8 +22,8 @@ sp_pcre* sp_pcre_compile(const char* const pattern) { | |||
| 22 | return ret; | 22 | return ret; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | bool sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, | 25 | bool ZEND_HOT sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, |
| 26 | size_t len) { | 26 | size_t len) { |
| 27 | int ret = 0; | 27 | int ret = 0; |
| 28 | 28 | ||
| 29 | assert(NULL != regexp); | 29 | assert(NULL != regexp); |
