* mu-msg-fields: rewrite the loops a bit
This commit is contained in:
@ -115,19 +115,15 @@ static const MuMsgField FIELD_DATA[] = {
|
|||||||
MU_MSG_FIELD_ID_TIMESTAMP,
|
MU_MSG_FIELD_ID_TIMESTAMP,
|
||||||
MU_MSG_FIELD_TYPE_TIME_T,
|
MU_MSG_FIELD_TYPE_TIME_T,
|
||||||
FLAG_GMIME
|
FLAG_GMIME
|
||||||
},
|
}
|
||||||
|
|
||||||
{ NULL, NULL, NULL, 0, 0, 0 }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
mu_msg_field_foreach (MuMsgFieldForEachFunc func, gconstpointer data)
|
mu_msg_field_foreach (MuMsgFieldForEachFunc func, gconstpointer data)
|
||||||
{
|
{
|
||||||
const MuMsgField* cursor = &FIELD_DATA[0];
|
int i;
|
||||||
while (cursor->_name) {
|
for (i = 0; i != sizeof(FIELD_DATA)/sizeof(FIELD_DATA[0]); ++i)
|
||||||
func (cursor, data);
|
func (&FIELD_DATA[i], data);
|
||||||
++cursor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef gboolean (*FieldMatchFunc) (const MuMsgField *field,
|
typedef gboolean (*FieldMatchFunc) (const MuMsgField *field,
|
||||||
@ -136,12 +132,11 @@ typedef gboolean (*FieldMatchFunc) (const MuMsgField *field,
|
|||||||
static const MuMsgField*
|
static const MuMsgField*
|
||||||
find_field (FieldMatchFunc matcher, gconstpointer data)
|
find_field (FieldMatchFunc matcher, gconstpointer data)
|
||||||
{
|
{
|
||||||
const MuMsgField* cursor = &FIELD_DATA[0];
|
int i;
|
||||||
while (cursor->_name) {
|
for (i = 0; i != sizeof(FIELD_DATA)/sizeof(FIELD_DATA[0]); ++i)
|
||||||
if (matcher (cursor, data))
|
if (matcher(&FIELD_DATA[i], data))
|
||||||
return cursor;
|
return &FIELD_DATA[i];
|
||||||
++cursor;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user