From: Jan 'Moskyt' Matejka Date: Thu, 19 Jul 2012 07:59:52 +0000 (+0200) Subject: Fastbuf: fbmulti: O(N^2) multiappend fixed X-Git-Tag: v5.99~119 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=f7645db376f3aa144ab700184f5cdd0ec40e61c9;p=libucw.git Fastbuf: fbmulti: O(N^2) multiappend fixed --- diff --git a/ucw/fb-multi.c b/ucw/fb-multi.c index 715705c6..9acf8b0f 100644 --- a/ucw/fb-multi.c +++ b/ucw/fb-multi.c @@ -183,23 +183,6 @@ fbmulti_seek(struct fastbuf *f, ucw_off_t pos, int whence) } } -static void -fbmulti_update_capability(struct fastbuf *f) -{ - // FB Multi is only a proxy to other fastbufs ... if any of them lacks - // support of any feature, FB Multi also provides no support of that feature - f->refill = fbmulti_refill; - f->seek = fbmulti_seek; - - CLIST_FOR_EACH(struct subbuf *, n, *(FB_MULTI(f)->subbufs)) - { - ASSERT(n->fb->refill); - - if (!n->fb->seek) - f->seek = NULL; - } -} - static void fbmulti_close(struct fastbuf *f) { @@ -242,6 +225,8 @@ fbmulti_create(uns bufsize, ...) } fb_out->name = FB_MULTI_NAME; + f->refill = fbmulti_refill; + f->seek = fbmulti_seek; fb_out->close = fbmulti_close; @@ -251,6 +236,10 @@ fbmulti_create(uns bufsize, ...) void fbmulti_append(struct fastbuf *f, struct fastbuf *fb) { + ASSERT(fb->refill); + if (!fb->seek) + f->seek = NULL; + struct subbuf *sb = mp_alloc(FB_MULTI(f)->mp, sizeof(struct subbuf)); sb->fb = fb; clist_add_tail(FB_MULTI(f)->subbufs, &(sb->n));