gmime r1443 - in trunk: . gmime
- From: fejj svn gnome org
- To: svn-commits-list gnome org
- Subject: gmime r1443 - in trunk: . gmime
- Date: Fri, 12 Sep 2008 13:06:20 +0000 (UTC)
Author: fejj
Date: Fri Sep 12 13:06:19 2008
New Revision: 1443
URL: http://svn.gnome.org/viewvc/gmime?rev=1443&view=rev
Log:
2008-09-12 Jeffrey Stedfast <fejj novell com>
I/O Optimization
* gmime/gmime-parser.c (parser_fill): Now takes an 'atleast'
argument which we use to decide whether we should bother calling
read() or not. If we have more than 'atleast' bytes left in our
buffer, we don't read.
(parser_scan_content): Take advantage of the 'atleast' argument to
parser_fill().
(parser_step_headers): Same.
(parser_step_from): Here too.
(parser_skip_line): And here.
Modified:
trunk/ChangeLog
trunk/gmime/gmime-parser.c
Modified: trunk/gmime/gmime-parser.c
==============================================================================
--- trunk/gmime/gmime-parser.c (original)
+++ trunk/gmime/gmime-parser.c Fri Sep 12 13:06:19 2008
@@ -594,7 +594,7 @@
static ssize_t
-parser_fill (GMimeParser *parser)
+parser_fill (GMimeParser *parser, size_t atleast)
{
struct _GMimeParserPrivate *priv = parser->priv;
char *inbuf, *inptr, *inend;
@@ -608,6 +608,9 @@
g_assert (inptr <= inend);
+ if (inlen > atleast)
+ return inlen;
+
/* attempt to align 'inend' with realbuf + SCAN_HEAD */
if (inptr >= inbuf) {
inbuf -= inlen < SCAN_HEAD ? inlen : SCAN_HEAD;
@@ -628,7 +631,7 @@
priv->inptr = inptr;
priv->inend = inbuf;
- inend = priv->realbuf + SCAN_HEAD + SCAN_BUF - 1;
+ inend = priv->realbuf + SCAN_HEAD + SCAN_BUF;
if ((nread = g_mime_stream_read (priv->stream, inbuf, inend - inbuf)) > 0)
priv->inend += nread;
@@ -707,7 +710,7 @@
do {
refill:
- if (parser_fill (parser) <= left) {
+ if (parser_fill (parser, MAX (SCAN_HEAD, left)) <= left) {
/* failed to find a From line; EOF reached */
priv->state = GMIME_PARSER_STATE_ERROR;
priv->inptr = priv->inend;
@@ -896,7 +899,7 @@
do {
refill:
- if (parser_fill (parser) <= left)
+ if (parser_fill (parser, MAX (SCAN_HEAD, left)) <= left)
break;
inptr = priv->inptr;
@@ -1118,7 +1121,7 @@
priv->inptr = inptr;
- if (parser_fill (parser) <= 0) {
+ if (parser_fill (parser, SCAN_HEAD) <= 0) {
inptr = priv->inptr;
rv = -1;
break;
@@ -1242,6 +1245,10 @@
* job correctly ;-)
**/
+
+/* we add 2 for \r\n */
+#define MAX_BOUNDARY_LEN(bounds) (bounds ? bounds->boundarylenmax + 2 : 0)
+
static int
parser_scan_content (GMimeParser *parser, GByteArray *content, int *crlf)
{
@@ -1249,6 +1256,7 @@
register char *inptr;
char *start, *inend;
size_t nleft, len;
+ size_t atleast;
int found = 0;
d(printf ("scan-content\n"));
@@ -1259,10 +1267,13 @@
start = inptr = priv->inptr;
+ /* figure out minimum amount of data we need */
+ atleast = MAX (SCAN_HEAD, MAX_BOUNDARY_LEN (priv->bounds));
+
do {
refill:
nleft = priv->inend - inptr;
- if (parser_fill (parser) <= 0) {
+ if (parser_fill (parser, atleast) <= 0) {
start = priv->inptr;
found = FOUND_EOS;
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]