mirror of https://github.com/djcb/mu.git
* lib: for sorting dates, use the strings as recorded in Xapian, rather than
converting to time_t; this saves ~ 5% when we list threaded results
This commit is contained in:
parent
9e6566989a
commit
6c071d940b
|
@ -67,7 +67,13 @@ mu_msg_doc_get_str_field (MuMsgDoc *self, MuMsgFieldId mfid)
|
|||
{
|
||||
g_return_val_if_fail (self, NULL);
|
||||
g_return_val_if_fail (mu_msg_field_id_is_valid(mfid), NULL);
|
||||
g_return_val_if_fail (mu_msg_field_is_string(mfid), NULL);
|
||||
|
||||
// disable this check:
|
||||
// g_return_val_if_fail (mu_msg_field_is_string(mfid), NULL);
|
||||
// because it's useful to get numerical field as strings,
|
||||
// for example when sorting (which is much faster if don't
|
||||
// have to convert to numbers first, esp. when it's a date
|
||||
// time_t)
|
||||
|
||||
try {
|
||||
const std::string s (self->doc().get_value(mfid));
|
||||
|
|
11
lib/mu-msg.c
11
lib/mu-msg.c
|
@ -779,12 +779,15 @@ mu_msg_cmp (MuMsg *m1, MuMsg *m2, MuMsgFieldId mfid)
|
|||
g_return_val_if_fail (m2, 0);
|
||||
g_return_val_if_fail (mu_msg_field_id_is_valid(mfid), 0);
|
||||
|
||||
if (mfid == MU_MSG_FIELD_ID_SUBJECT)
|
||||
return cmp_subject (get_str_field (m1, mfid),
|
||||
/* 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 (mu_msg_field_is_string (mfid))
|
||||
return cmp_str (get_str_field (m1, 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) */
|
||||
|
|
Loading…
Reference in New Issue