summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2001-05-28 10:57:23 +0000
committerWez Furlong <wez@php.net>2001-05-28 10:57:23 +0000
commit2bdef9c83ffea933d3654575d6bd38894d5856c6 (patch)
tree50e641901913cde4bb3664b8c4f27be4633ff4d7
parent7d52787a96f55eb96594e5c5a2f6519408f7ef80 (diff)
downloadphp-git-2bdef9c83ffea933d3654575d6bd38894d5856c6.tar.gz
Improved performance of message part extraction when using a PHP-space
callback.
-rwxr-xr-xext/mailparse/rfc2045.h6
-rwxr-xr-xext/mailparse/rfc2045cdecode.c13
2 files changed, 16 insertions, 3 deletions
diff --git a/ext/mailparse/rfc2045.h b/ext/mailparse/rfc2045.h
index 30d93e6bb8..388620d40e 100755
--- a/ext/mailparse/rfc2045.h
+++ b/ext/mailparse/rfc2045.h
@@ -195,6 +195,12 @@ char *rfc2045_content_base(struct rfc2045 *p);
char *rfc2045_append_url(const char *, const char *);
/* Do this with two arbitrary URLs */
+
+
+void rfc2045_add_workbuf(struct rfc2045 *h, const char *p, size_t len);
+void rfc2045_add_workbufch(struct rfc2045 *h, int c);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/ext/mailparse/rfc2045cdecode.c b/ext/mailparse/rfc2045cdecode.c
index 971c59d77b..858f48dfde 100755
--- a/ext/mailparse/rfc2045cdecode.c
+++ b/ext/mailparse/rfc2045cdecode.c
@@ -10,10 +10,15 @@
static int op_func(int c, void *dat)
{
- unsigned char C = (unsigned char)c;
struct rfc2045 * p = (struct rfc2045*)dat;
-
- (*p->udecode_func)(&C, 1, p->misc_decode_ptr);
+
+ rfc2045_add_workbufch(p, c);
+
+ /* drain buffer */
+ if (p->workbuflen >= 4096) {
+ (*p->udecode_func)(p->workbuf, p->workbuflen, p->misc_decode_ptr);
+ p->workbuflen = 0;
+ }
return c;
}
@@ -57,6 +62,8 @@ int rfc2045_cdecode_end(struct rfc2045 *p)
mbfl_convert_filter_flush(p->decode_filter);
mbfl_convert_filter_delete(p->decode_filter);
p->decode_filter = NULL;
+ if (p->workbuflen > 0)
+ (*p->udecode_func)(p->workbuf, p->workbuflen, p->misc_decode_ptr);
}
return 0;
}