comparison mcabber/mcabber/hbuf.c @ 1817:fb6d20a17584

Improve hbuf_remove_receipt() efficiency Do not use g_list_first() (that is, start searching from the bottom of the buffer).
author Mikael Berthe <mikael@lilotux.net>
date Mon, 22 Mar 2010 23:39:01 +0100
parents e6d355e50d7a
children e8cebf5fd36c
comparison
equal deleted inserted replaced
1816:6ac5718f8d25 1817:fb6d20a17584
483 // Returns TRUE if it was found and removed, otherwise FALSE 483 // Returns TRUE if it was found and removed, otherwise FALSE
484 gboolean hbuf_remove_receipt(GList *hbuf, gpointer xep184) 484 gboolean hbuf_remove_receipt(GList *hbuf, gpointer xep184)
485 { 485 {
486 hbuf_block *blk; 486 hbuf_block *blk;
487 487
488 hbuf = g_list_first(hbuf); 488 hbuf = g_list_last(hbuf);
489 489
490 for ( ; hbuf; hbuf = g_list_next(hbuf)) { 490 for ( ; hbuf; hbuf = g_list_previous(hbuf)) {
491 blk = (hbuf_block*)(hbuf->data); 491 blk = (hbuf_block*)(hbuf->data);
492 if (blk->prefix.xep184 == xep184) { 492 if (blk->prefix.xep184 == xep184) {
493 blk->prefix.xep184 = NULL; 493 blk->prefix.xep184 = NULL;
494 blk->prefix.flags ^= HBB_PREFIX_RECEIPT; 494 blk->prefix.flags ^= HBB_PREFIX_RECEIPT;
495 return TRUE; 495 return TRUE;