6d49c343fc
this removes the pathological O(<number of sync records> * <number of new messages>) case at the cost of being a bit more cpu-intensive (but O(<number of all messages>)) for old messages.