mu: remove some unneeded code
Dead code, and replace mu_canonicalize_filename with g_canonicalize_filename.
This commit is contained in:
@ -737,76 +737,6 @@ Mu::mu_msg_contact_foreach(MuMsg* msg, MuMsgContactForeachFunc func, gpointer us
|
||||
g_return_if_reached();
|
||||
}
|
||||
|
||||
static int
|
||||
cmp_str(const char* s1, const char* s2)
|
||||
{
|
||||
if (s1 == s2)
|
||||
return 0;
|
||||
else if (!s1)
|
||||
return -1;
|
||||
else if (!s2)
|
||||
return 1;
|
||||
|
||||
/* optimization 1: ascii */
|
||||
if (isascii(s1[0]) && isascii(s2[0])) {
|
||||
int diff;
|
||||
diff = tolower(s1[0]) - tolower(s2[0]);
|
||||
if (diff != 0)
|
||||
return diff;
|
||||
}
|
||||
|
||||
/* utf 8 */
|
||||
{
|
||||
char *u1, *u2;
|
||||
int diff;
|
||||
|
||||
u1 = g_utf8_strdown(s1, -1);
|
||||
u2 = g_utf8_strdown(s2, -1);
|
||||
|
||||
diff = g_utf8_collate(u1, u2);
|
||||
|
||||
g_free(u1);
|
||||
g_free(u2);
|
||||
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
cmp_subject(const char* s1, const char* s2)
|
||||
{
|
||||
if (s1 == s2)
|
||||
return 0;
|
||||
else if (!s1)
|
||||
return -1;
|
||||
else if (!s2)
|
||||
return 1;
|
||||
|
||||
return cmp_str(mu_str_subject_normalize(s1), mu_str_subject_normalize(s2));
|
||||
}
|
||||
|
||||
int
|
||||
Mu::mu_msg_cmp(MuMsg* m1, MuMsg* m2, MuMsgFieldId mfid)
|
||||
{
|
||||
g_return_val_if_fail(m1, 0);
|
||||
g_return_val_if_fail(m2, 0);
|
||||
g_return_val_if_fail(mu_msg_field_id_is_valid(mfid), 0);
|
||||
|
||||
/* even though date is a numeric field, we can sort it by its
|
||||
* string repr. in the database, which is much faster */
|
||||
if (mfid == MU_MSG_FIELD_ID_DATE || mu_msg_field_is_string(mfid))
|
||||
return cmp_str(get_str_field(m1, mfid), get_str_field(m2, mfid));
|
||||
|
||||
if (mfid == MU_MSG_FIELD_ID_SUBJECT)
|
||||
return cmp_subject(get_str_field(m1, mfid), get_str_field(m2, mfid));
|
||||
|
||||
/* TODO: note, we cast (potentially > MAXINT to int) */
|
||||
if (mu_msg_field_is_numeric(mfid))
|
||||
return get_num_field(m1, mfid) - get_num_field(m2, mfid);
|
||||
|
||||
return 0; /* TODO: handle lists */
|
||||
}
|
||||
|
||||
gboolean
|
||||
Mu::mu_msg_is_readable(MuMsg* self)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user