diff options
| author | jvoisin | 2022-07-13 02:26:56 +0200 |
|---|---|---|
| committer | jvoisin | 2022-07-13 02:26:56 +0200 |
| commit | ce95c32c91c1d78cfb7603699b6b10e54e931f45 (patch) | |
| tree | a99b9125160ac6b9a868c5d69fd3e1460e38da88 | |
| parent | 7deb974c164d4f7cfbe13c5403d8cd36a0cbc2eb (diff) | |
More micro-optimizations
| -rw-r--r-- | src/sp_utils.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c index 57ecf67..3436328 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -95,7 +95,7 @@ int sp_log_request(const zend_string* restrict folder, const zend_string* restri | |||
| 95 | char const* const current_filename = zend_get_executed_filename(TSRMLS_C); | 95 | char const* const current_filename = zend_get_executed_filename(TSRMLS_C); |
| 96 | const int current_line = zend_get_executed_lineno(TSRMLS_C); | 96 | const int current_line = zend_get_executed_lineno(TSRMLS_C); |
| 97 | char filename[PATH_MAX] = {0}; | 97 | char filename[PATH_MAX] = {0}; |
| 98 | const struct { | 98 | static const struct { |
| 99 | char const* const str; | 99 | char const* const str; |
| 100 | const int key; | 100 | const int key; |
| 101 | } zones[] = {{"GET", TRACK_VARS_GET}, {"POST", TRACK_VARS_POST}, | 101 | } zones[] = {{"GET", TRACK_VARS_GET}, {"POST", TRACK_VARS_POST}, |
| @@ -146,7 +146,9 @@ int sp_log_request(const zend_string* restrict folder, const zend_string* restri | |||
| 146 | fputs(ZSTR_VAL(text_repr), file); | 146 | fputs(ZSTR_VAL(text_repr), file); |
| 147 | fputc('\n', file); | 147 | fputc('\n', file); |
| 148 | 148 | ||
| 149 | fprintf(file, "FILE: %s:%d\n", current_filename, current_line); | 149 | fputs("FILE: ", file); |
| 150 | fputs(current_filename, file); | ||
| 151 | fprintf(file, ":%d\n", current_line); | ||
| 150 | 152 | ||
| 151 | orig_execute_data = EG(current_execute_data); | 153 | orig_execute_data = EG(current_execute_data); |
| 152 | current = EG(current_execute_data); | 154 | current = EG(current_execute_data); |
| @@ -155,7 +157,9 @@ int sp_log_request(const zend_string* restrict folder, const zend_string* restri | |||
| 155 | char* const complete_path_function = get_complete_function_path(current); | 157 | char* const complete_path_function = get_complete_function_path(current); |
| 156 | if (complete_path_function) { | 158 | if (complete_path_function) { |
| 157 | const int current_line = zend_get_executed_lineno(TSRMLS_C); | 159 | const int current_line = zend_get_executed_lineno(TSRMLS_C); |
| 158 | fprintf(file, "STACKTRACE: %s:%d\n", complete_path_function, current_line); | 160 | fputs("STACKTRACE: ", file); |
| 161 | fputs(complete_path_function, file); | ||
| 162 | fprintf(file, ":%d\n", current_line); | ||
| 159 | efree(complete_path_function); | 163 | efree(complete_path_function); |
| 160 | } | 164 | } |
| 161 | current = current->prev_execute_data; | 165 | current = current->prev_execute_data; |
| @@ -171,26 +175,30 @@ int sp_log_request(const zend_string* restrict folder, const zend_string* restri | |||
| 171 | } | 175 | } |
| 172 | 176 | ||
| 173 | HashTable* ht = Z_ARRVAL(PG(http_globals)[zones[i].key]); | 177 | HashTable* ht = Z_ARRVAL(PG(http_globals)[zones[i].key]); |
| 174 | fprintf(file, "%s:", zones[i].str); | 178 | fputs(zones[i].str, file); |
| 179 | fputc(':', file); | ||
| 175 | ZEND_HASH_FOREACH_STR_KEY_VAL(ht, variable_key, variable_value) { | 180 | ZEND_HASH_FOREACH_STR_KEY_VAL(ht, variable_key, variable_value) { |
| 176 | smart_str a; | 181 | smart_str a = {0}; |
| 177 | |||
| 178 | memset(&a, 0, sizeof(a)); | ||
| 179 | php_var_export_ex(variable_value, 1, &a); | 182 | php_var_export_ex(variable_value, 1, &a); |
| 180 | ZSTR_VAL(a.s)[ZSTR_LEN(a.s)] = '\0'; | 183 | ZSTR_VAL(a.s)[ZSTR_LEN(a.s)] = '\0'; |
| 181 | fprintf(file, "%s=%s ", ZSTR_VAL(variable_key), ZSTR_VAL(a.s)); | 184 | fputs(ZSTR_VAL(variable_key), file); |
| 185 | fputc('=', file); | ||
| 186 | fputs(ZSTR_VAL(a.s), file); | ||
| 187 | fputc(' ', file); | ||
| 182 | zend_string_release(a.s); | 188 | zend_string_release(a.s); |
| 183 | } | 189 | } |
| 184 | ZEND_HASH_FOREACH_END(); | 190 | ZEND_HASH_FOREACH_END(); |
| 185 | fputs("\n", file); | 191 | fputc('\n', file); |
| 186 | } | 192 | } |
| 187 | 193 | ||
| 188 | if (UNEXPECTED(0 != SPG(in_eval))) { | 194 | if (UNEXPECTED(0 != SPG(in_eval))) { |
| 195 | fputs("EVAL_CODE: ", file); | ||
| 189 | #if PHP_VERSION_ID >= 80000 | 196 | #if PHP_VERSION_ID >= 80000 |
| 190 | fprintf(file, "EVAL_CODE: %s\n", ZSTR_VAL(SPG(eval_source_string))); | 197 | fputs(ZSTR_VAL(SPG(eval_source_string)), file); |
| 191 | #else | 198 | #else |
| 192 | fprintf(file, "EVAL_CODE: %s\n", Z_STRVAL_P(SPG(eval_source_string))); | 199 | fputs(Z_STRVAL_P(SPG(eval_source_string)), file); |
| 193 | #endif | 200 | #endif |
| 201 | fputc('\n', file); | ||
| 194 | } | 202 | } |
| 195 | 203 | ||
| 196 | fclose(file); | 204 | fclose(file); |
