summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2008-06-15 21:42:20 +0000
committerGreg Beaver <cellog@php.net>2008-06-15 21:42:20 +0000
commit4104786072fe60f0a3ee7b9eac504cacdad9304d (patch)
treee3b1cbacc3260ae388ac8cc06140294e2a9b5bd4 /ext
parentd8ed660a02460954efe2e9d6aff8bef72a182ae9 (diff)
downloadphp-git-4104786072fe60f0a3ee7b9eac504cacdad9304d.tar.gz
another optimization - move inode hash to initial manifest parsing, improves runtime perf of stat slightly
Diffstat (limited to 'ext')
-rw-r--r--ext/phar/phar.c1
-rwxr-xr-xext/phar/phar.pharbin15252 -> 15252 bytes
-rwxr-xr-xext/phar/phar_internal.h13
-rwxr-xr-xext/phar/phar_object.c1
-rw-r--r--ext/phar/stream.c19
-rw-r--r--ext/phar/tar.c1
-rw-r--r--ext/phar/zip.c1
7 files changed, 20 insertions, 16 deletions
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 906020a26a..10df6d4c9b 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -1070,6 +1070,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
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);
}
diff --git a/ext/phar/phar.phar b/ext/phar/phar.phar
index cf4484da2b..d45774867a 100755
--- a/ext/phar/phar.phar
+++ b/ext/phar/phar.phar
Binary files differ
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index 3d771f2393..85a2b8551c 100755
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -268,6 +268,8 @@ typedef struct _phar_entry_info {
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 int phar_validate_alias(const char *alias, int alias_len) /* {{{ *
}
/* }}} */
+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);
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 8d3becbef3..0c76b876d9 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -2104,6 +2104,7 @@ no_copy:
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);
}
diff --git a/ext/phar/stream.c b/ext/phar/stream.c
index a12f21c35c..4854aeb907 100644
--- a/ext/phar/stream.c
+++ b/ext/phar/stream.c
@@ -402,8 +402,6 @@ static int phar_stream_flush(php_stream *stream TSRMLS_DC) /* {{{ */
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 @@ void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_stat
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;
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index 8d4d0355f5..618ff76997 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -413,6 +413,7 @@ bail:
} 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)) {
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 3026c3b6f5..c36f2a70cc 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -462,6 +462,7 @@ foundit:
/* 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;