Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:2275 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50092 invoked from network); 11 Jun 2003 01:41:12 -0000 Received: from unknown (HELO asuka.nerv) (24.112.18.98) by pb1.pair.com with SMTP; 11 Jun 2003 01:41:12 -0000 Received: (qmail 31937 invoked from network); 11 Jun 2003 01:49:05 -0000 Received: from rei.nerv (HELO dummy.com) (rei@192.168.1.1) by asuka.nerv with SMTP; 11 Jun 2003 01:49:05 -0000 Reply-To: ilia@prohost.org Organization: Prohost.org To: internals@lists.php.net, Andi Gutmans Date: Tue, 10 Jun 2003 21:51:05 -0400 User-Agent: KMail/1.5 References: <200306102149.16190.ilia@prohost.org> In-Reply-To: <200306102149.16190.ilia@prohost.org> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_Jso5+qv8QYQj2nM" Message-ID: <200306102151.05166.ilia@prohost.org> Subject: Re: [PHP-DEV] Benchmarking 4.3.2 vs 4.1.2 From: ilia@prohost.org ("Ilia A.") --Boundary-00=_Jso5+qv8QYQj2nM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 --Boundary-00=_Jso5+qv8QYQj2nM Content-Type: text/plain; charset="iso-8859-1"; name="TSRM1.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="TSRM1.txt" 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; --Boundary-00=_Jso5+qv8QYQj2nM--