[gmime: 6/8] Don't need to use a filtered stream if mime_part is NULL
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime: 6/8] Don't need to use a filtered stream if mime_part is NULL
- Date: Fri, 3 Nov 2017 14:35:51 +0000 (UTC)
commit 54eee77814e534524b89f939c27b25603e511528
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date: Thu Nov 2 16:15:05 2017 -0400
Don't need to use a filtered stream if mime_part is NULL
This is also a slight optimization because the headers
won't need to be filtered through 2 newline filters.
gmime/gmime-message.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/gmime/gmime-message.c b/gmime/gmime-message.c
index d5dc14c..15fea3c 100644
--- a/gmime/gmime-message.c
+++ b/gmime/gmime-message.c
@@ -455,23 +455,23 @@ write_headers_to_stream (GMimeObject *object, GMimeFormatOptions *options, GMime
{
GMimeMessage *message = (GMimeMessage *) object;
GMimeObject *mime_part = message->mime_part;
- ssize_t nwritten, total = 0;
- GMimeStream *filtered;
- GMimeFilter *filter;
-
- filter = g_mime_format_options_create_newline_filter (options, FALSE);
- filtered = g_mime_stream_filter_new (stream);
- g_mime_stream_filter_add ((GMimeStreamFilter *) filtered, filter);
- g_object_unref (filter);
if (mime_part != NULL) {
int body_count = g_mime_header_list_get_count (mime_part->headers);
int count = g_mime_header_list_get_count (object->headers);
GMimeHeader *header, *body_header;
+ ssize_t nwritten, total = 0;
gint64 body_offset, offset;
+ GMimeStream *filtered;
+ GMimeFilter *filter;
int body_index = 0;
int index = 0;
+ filtered = g_mime_stream_filter_new (stream);
+ filter = g_mime_format_options_create_newline_filter (options, FALSE);
+ g_mime_stream_filter_add ((GMimeStreamFilter *) filtered, filter);
+ g_object_unref (filter);
+
while (index < count && body_index < body_count) {
body_header = g_mime_header_list_get_header_at (mime_part->headers, body_index);
if ((body_offset = g_mime_header_get_offset (body_header)) < 0)
@@ -540,10 +540,7 @@ write_headers_to_stream (GMimeObject *object, GMimeFormatOptions *options, GMime
return total;
}
- nwritten = g_mime_header_list_write_to_stream (object->headers, options, filtered);
- g_object_unref (filtered);
-
- return nwritten;
+ return g_mime_header_list_write_to_stream (object->headers, options, stream);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]