[evolution-data-server] EVCard: Slightly speed up vCard parsing and export to text
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] EVCard: Slightly speed up vCard parsing and export to text
- Date: Fri, 14 Oct 2022 09:33:48 +0000 (UTC)
commit be7f1833a73358deae6f6f8a31034998bf878d1b
Author: Milan Crha <mcrha redhat com>
Date: Fri Oct 14 11:32:29 2022 +0200
EVCard: Slightly speed up vCard parsing and export to text
By not doing repetitive string comparisons in a cycle.
src/addressbook/libebook-contacts/e-vcard.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/addressbook/libebook-contacts/e-vcard.c b/src/addressbook/libebook-contacts/e-vcard.c
index ee2f620be..da39f7934 100644
--- a/src/addressbook/libebook-contacts/e-vcard.c
+++ b/src/addressbook/libebook-contacts/e-vcard.c
@@ -362,6 +362,8 @@ read_attribute_value (EVCardAttribute *attr,
{
gchar *lp = *p;
const gchar *chunk_start = NULL;
+ gboolean is_singlevalue_type;
+ gboolean is_categories;
GString *str;
#define WRITE_CHUNK() G_STMT_START { \
@@ -370,6 +372,9 @@ read_attribute_value (EVCardAttribute *attr,
chunk_start = NULL; \
} } G_STMT_END
+ is_singlevalue_type = e_vcard_attribute_is_singlevalue_type (attr);
+ is_categories = !g_ascii_strcasecmp (attr->name, EVC_CATEGORIES);
+
/* read in the value */
str = g_string_sized_new (16);
for (lp = skip_newline ( *p, quoted_printable);
@@ -443,8 +448,8 @@ read_attribute_value (EVCardAttribute *attr,
}
lp = g_utf8_next_char (lp);
}
- else if ((*lp == ';' && !e_vcard_attribute_is_singlevalue_type (attr)) ||
- (*lp == ',' && !g_ascii_strcasecmp (attr->name, "CATEGORIES"))) {
+ else if ((*lp == ';' && !is_singlevalue_type) ||
+ (*lp == ',' && is_categories)) {
WRITE_CHUNK ();
if (charset) {
gchar *tmp;
@@ -1386,6 +1391,7 @@ e_vcard_to_string_vcard_30 (EVCard *evc)
GString *attr_str;
glong len;
EVCardAttributeParam *quoted_printable_param = NULL;
+ gboolean is_categories;
if (!g_ascii_strcasecmp (attr->name, "VERSION"))
continue;
@@ -1463,6 +1469,8 @@ e_vcard_to_string_vcard_30 (EVCard *evc)
g_string_append_c (attr_str, ':');
+ is_categories = !g_ascii_strcasecmp (attr->name, EVC_CATEGORIES);
+
for (v = attr->values; v; v = v->next) {
gchar *value = v->data;
gchar *escaped_value = NULL;
@@ -1487,7 +1495,7 @@ e_vcard_to_string_vcard_30 (EVCard *evc)
/* XXX toshok - i hate you, rfc 2426.
* why doesn't CATEGORIES use a; like
* a normal list attribute? */
- if (!g_ascii_strcasecmp (attr->name, "CATEGORIES"))
+ if (is_categories)
g_string_append_c (attr_str, ',');
else
g_string_append_c (attr_str, ';');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]