There are a several things that could be done to speed file opening process up. Attached is a fairly simple patch that in most cases optimizes potentially expensive code that looks for ../ and ./ in the path.
Ilia
Index: TSRM/tsrm_virtual_cwd.c =================================================================== RCS file: /repository/TSRM/tsrm_virtual_cwd.c,v retrieving revision 1.41.2.3 diff -u -3 -p -r1.41.2.3 tsrm_virtual_cwd.c --- TSRM/tsrm_virtual_cwd.c 4 Jun 2003 00:01:00 -0000 1.41.2.3 +++ TSRM/tsrm_virtual_cwd.c 11 Jun 2003 01:37:28 -0000 @@ -106,6 +106,22 @@ static int php_check_dots(const char *el #define TOKENIZER_STRING "/" #endif +static int php_is_dots(const char *element, int n) +{ + char *p = element; + int l = n; + + while ((p = memchr(p, '.', l))) { + if (*(p + 1) == DEFAULT_SLASH) { + return 1; + } + p = p + 1; + l = n - (p - element); + } + + return 0; +} + /* default macros */ @@ -367,6 +383,9 @@ CWD_API int virtual_file_ex(cwd_state *s if (state->cwd_length > 0 || IS_ABSOLUTE_PATH(path, path_length)) { + if (!php_is_dots(path, path_length)) { + goto done; + } ptr = tsrm_strtok_r(path_copy, TOKENIZER_STRING, &tok); while (ptr) { ptr_length = strlen(ptr); @@ -421,6 +440,7 @@ CWD_API int virtual_file_ex(cwd_state *s state->cwd_length++; } } else { +done: state->cwd = (char *) realloc(state->cwd, path_length+1); memcpy(state->cwd, path, path_length+1); state->cwd_length = path_length;
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php