[Commits] [SCM] claws branch, master, updated. 3.17.0-84-g2afd558

Colin colin at claws-mail.org
Sat Oct 6 12:47:11 CEST 2018


The branch, master has been updated
       via  2afd55869a7b6ad215cab2f19b1c23a385ae87d9 (commit)
      from  53b770e396312512a2c0553fb7484aa8e106d2f5 (commit)

Summary of changes:
 src/matcher.c    |   15 +--------------
 src/procheader.c |   18 ++++++++++++++++++
 src/procheader.h |    2 ++
 3 files changed, 21 insertions(+), 14 deletions(-)


- Log -----------------------------------------------------------------
commit 2afd55869a7b6ad215cab2f19b1c23a385ae87d9
Author: Colin Leroy <colin at colino.net>
Date:   Sat Oct 6 12:46:48 2018 +0200

    Don't bother parsing headers when we want to skip them
    Speeds up body-only search

diff --git a/src/matcher.c b/src/matcher.c
index 4a0392d..c58c559 100644
--- a/src/matcher.c
+++ b/src/matcher.c
@@ -1330,19 +1330,6 @@ void matcherlist_free(MatcherList *cond)
 }
 
 /*!
- *\brief	Skip all headers in a message file
- *
- *\param	fp Message file
- */
-static void matcherlist_skip_headers(FILE *fp)
-{
-	gchar *buf = NULL;
-
-	while (procheader_get_one_field(&buf, fp, NULL) != -1)
-		g_free(buf);
-}
-
-/*!
  *\brief	Check if a header matches a matcher condition
  *
  *\param	matcher Matcher structure to check header for
@@ -1848,7 +1835,7 @@ static gboolean matcherlist_match_file(MatcherList *matchers, MsgInfo *info,
 		if (matcherlist_match_headers(matchers, fp))
 			read_body = FALSE;
 	} else {
-		matcherlist_skip_headers(fp);
+		procheader_skip_headers(fp);
 	}
 
 	/* read the body */
diff --git a/src/procheader.c b/src/procheader.c
index 174e283..6a98f12 100644
--- a/src/procheader.c
+++ b/src/procheader.c
@@ -83,6 +83,24 @@ static gint string_get_one_field(gchar **buf, char **str,
 				     TRUE);
 }
 
+gboolean procheader_skip_headers(FILE *fp)
+{
+	gchar *buf = g_malloc(BUFFSIZE);
+	do {
+		if (fgets_crlf(buf, BUFFSIZE - 1, fp) == NULL) {
+			g_free(buf);
+			return FALSE;
+		}
+		if (buf[0] == '\r' || buf[0] == '\n') {
+			break;
+		}
+	} while (TRUE);
+	g_free(buf);
+
+	return TRUE;
+}
+
+
 static char *string_getline(char *buf, size_t len, char **str)
 {
 	gboolean is_cr = FALSE;
diff --git a/src/procheader.h b/src/procheader.h
index 0588f30..50e6c55 100644
--- a/src/procheader.h
+++ b/src/procheader.h
@@ -51,6 +51,8 @@ GPtrArray *procheader_get_header_array_asis	(FILE		*fp);
 void procheader_header_array_destroy		(GPtrArray	*harray);
 void procheader_header_free			(Header		*header);
 
+gboolean procheader_skip_headers(FILE *fp);
+
 void procheader_get_header_fields	(FILE		*fp,
 					 HeaderEntry	 hentry[]);
 MsgInfo *procheader_parse_file		(const gchar	*file,

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list