cellog Sun Jun 15 21:42:20 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/phar phar.c phar.phar phar_internal.h phar_object.c
stream.c tar.c zip.c
Log:
another optimization - move inode hash to initial manifest parsing, improves
runtime perf of stat slightly
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.17&r2=1.370.2.18&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.370.2.17 php-src/ext/phar/phar.c:1.370.2.18
--- php-src/ext/phar/phar.c:1.370.2.17 Sun Jun 15 21:15:29 2008
+++ php-src/ext/phar/phar.c Sun Jun 15 21:42:19 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar.c,v 1.370.2.17 2008/06/15 21:15:29 cellog Exp $ */
+/* $Id: phar.c,v 1.370.2.18 2008/06/15 21:42:19 cellog Exp $ */
#define PHAR_MAIN 1
#include "phar_internal.h"
@@ -1070,6 +1070,7 @@
manifest_flags |= (entry.flags & PHAR_ENT_COMPRESSION_MASK);
/* if signature matched, no need to check CRC32 for each file */
entry.is_crc_checked = (manifest_flags & PHAR_HDR_SIGNATURE ? 1
: 0);
+ phar_set_inode(&entry TSRMLS_CC);
zend_hash_add(&mydata->manifest, entry.filename,
entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL);
}
@@ -3397,7 +3398,7 @@
php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION);
- php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.17 $");
+ php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.18 $");
php_info_print_table_row(2, "Phar-based phar archives", "enabled");
php_info_print_table_row(2, "Tar-based phar archives", "enabled");
php_info_print_table_row(2, "ZIP-based phar archives", "enabled");
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.phar?r1=1.7.2.16&r2=1.7.2.17&diff_format=u
Index: php-src/ext/phar/phar.phar
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_internal.h?r1=1.109.2.13&r2=1.109.2.14&diff_format=u
Index: php-src/ext/phar/phar_internal.h
diff -u php-src/ext/phar/phar_internal.h:1.109.2.13
php-src/ext/phar/phar_internal.h:1.109.2.14
--- php-src/ext/phar/phar_internal.h:1.109.2.13 Sun Jun 15 21:15:29 2008
+++ php-src/ext/phar/phar_internal.h Sun Jun 15 21:42:20 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_internal.h,v 1.109.2.13 2008/06/15 21:15:29 cellog Exp $ */
+/* $Id: phar_internal.h,v 1.109.2.14 2008/06/15 21:42:20 cellog Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -268,6 +268,8 @@
int is_zip:1;
/* for cached phar entries */
int is_persistent:1;
+ /* for stat */
+ unsigned short inode;
} phar_entry_info;
/* information about a phar file (the archive itself) */
@@ -408,6 +410,17 @@
}
/* }}} */
+static inline void phar_set_inode(phar_entry_info *entry TSRMLS_DC) /* {{{ */
+{
+ char tmp[MAXPATHLEN];
+ int tmp_len;
+
+ tmp_len = entry->filename_len + entry->phar->fname_len;
+ memcpy(tmp, entry->phar->fname, entry->phar->fname_len);
+ memcpy(tmp + entry->phar->fname_len, entry->filename,
entry->filename_len);
+ entry->inode = (unsigned short)zend_get_hash_value(tmp, tmp_len);
+}
+/* }}} */
void phar_request_initialize(TSRMLS_D);
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_object.c?r1=1.266.2.21&r2=1.266.2.22&diff_format=u
Index: php-src/ext/phar/phar_object.c
diff -u php-src/ext/phar/phar_object.c:1.266.2.21
php-src/ext/phar/phar_object.c:1.266.2.22
--- php-src/ext/phar/phar_object.c:1.266.2.21 Sun Jun 15 21:15:29 2008
+++ php-src/ext/phar/phar_object.c Sun Jun 15 21:42:20 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar_object.c,v 1.266.2.21 2008/06/15 21:15:29 cellog Exp $ */
+/* $Id: phar_object.c,v 1.266.2.22 2008/06/15 21:42:20 cellog Exp $ */
#include "phar_internal.h"
#include "func_interceptors.h"
@@ -2104,6 +2104,7 @@
newentry.is_modified = 1;
newentry.phar = phar;
newentry.old_flags = newentry.flags &
~PHAR_ENT_COMPRESSION_MASK; /* remove compression from old_flags */
+ phar_set_inode(&newentry TSRMLS_CC);
zend_hash_add(&(phar->manifest), newentry.filename,
newentry.filename_len, (void*)&newentry, sizeof(phar_entry_info), NULL);
phar_add_virtual_dirs(phar, newentry.filename,
newentry.filename_len TSRMLS_CC);
}
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/stream.c?r1=1.27.2.4&r2=1.27.2.5&diff_format=u
Index: php-src/ext/phar/stream.c
diff -u php-src/ext/phar/stream.c:1.27.2.4 php-src/ext/phar/stream.c:1.27.2.5
--- php-src/ext/phar/stream.c:1.27.2.4 Sun Jun 15 18:15:48 2008
+++ php-src/ext/phar/stream.c Sun Jun 15 21:42:20 2008
@@ -402,8 +402,6 @@
void phar_dostat(phar_archive_data *phar, phar_entry_info *data,
php_stream_statbuf *ssb,
zend_bool is_temp_dir, char *alias, int alias_len
TSRMLS_DC)
{
- char *tmp;
- int tmp_len;
memset(ssb, 0, sizeof(php_stream_statbuf));
if (!is_temp_dir && !data->is_dir) {
@@ -454,23 +452,12 @@
ssb->sb.st_nlink = 1;
ssb->sb.st_rdev = -1;
- if (data) {
- tmp_len = data->filename_len + alias_len;
- } else {
- tmp_len = alias_len + 1;
- }
- tmp = (char *) emalloc(tmp_len);
- memcpy(tmp, alias, alias_len);
- if (data) {
- memcpy(tmp + alias_len, data->filename, data->filename_len);
- } else {
- *(tmp+alias_len) = '/';
- }
/* this is only for APC, so use /dev/null device - no chance of
conflict there! */
ssb->sb.st_dev = 0xc;
/* generate unique inode number for alias/filename, so no phars will
conflict */
- ssb->sb.st_ino = (unsigned short)zend_get_hash_value(tmp, tmp_len);
- efree(tmp);
+ if (!is_temp_dir) {
+ ssb->sb.st_ino = data->inode;
+ }
#ifndef PHP_WIN32
ssb->sb.st_blksize = -1;
ssb->sb.st_blocks = -1;
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tar.c?r1=1.55.2.8&r2=1.55.2.9&diff_format=u
Index: php-src/ext/phar/tar.c
diff -u php-src/ext/phar/tar.c:1.55.2.8 php-src/ext/phar/tar.c:1.55.2.9
--- php-src/ext/phar/tar.c:1.55.2.8 Sun Jun 15 18:15:48 2008
+++ php-src/ext/phar/tar.c Sun Jun 15 21:42:20 2008
@@ -413,6 +413,7 @@
} else if (entry.tar_type == TAR_SYMLINK) {
entry.link = estrdup(hdr->linkname);
}
+ phar_set_inode(&entry TSRMLS_CC);
zend_hash_add(&myphar->manifest, entry.filename,
entry.filename_len, (void*)&entry, sizeof(phar_entry_info), (void **)
&newentry);
if (entry.filename_len >= sizeof(".phar/.metadata")-1 &&
!memcmp(entry.filename, ".phar/.metadata", sizeof(".phar/.metadata")-1)) {
if (FAILURE == phar_tar_process_metadata(newentry, fp
TSRMLS_CC)) {
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/zip.c?r1=1.47.2.6&r2=1.47.2.7&diff_format=u
Index: php-src/ext/phar/zip.c
diff -u php-src/ext/phar/zip.c:1.47.2.6 php-src/ext/phar/zip.c:1.47.2.7
--- php-src/ext/phar/zip.c:1.47.2.6 Sun Jun 15 18:15:48 2008
+++ php-src/ext/phar/zip.c Sun Jun 15 21:42:20 2008
@@ -462,6 +462,7 @@
/* return to central directory parsing */
php_stream_seek(fp, saveloc, SEEK_SET);
}
+ phar_set_inode(&entry TSRMLS_CC);
zend_hash_add(&mydata->manifest, entry.filename,
entry.filename_len, (void *)&entry,sizeof(phar_entry_info), NULL);
}
mydata->fp = fp;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php