Ok, *this* is the way we want it structured internally.
authorArt Cancro <ajc@citadel.org>
Tue, 12 Oct 2010 21:43:52 +0000 (17:43 -0400)
committerArt Cancro <ajc@citadel.org>
Tue, 12 Oct 2010 21:43:52 +0000 (17:43 -0400)
Now it's time to refactor it to O(N) instead of O(n log n)

webcit/blogview_renderer.c

index d4f1ee4a913c921cfab0a55792c319e67cadf177..8dc7036e509e21765960e8752e2f9e330a700a79 100644 (file)
@@ -121,7 +121,9 @@ int blogview_sortfunc(const void *s1, const void *s2) {
 void blogview_learn_thread_references(struct blogpost *bp)
 {
        StrBuf *Buf;
+       StrBuf *r;
        Buf = NewStrBuf();
+       r = NewStrBuf();
        serv_printf("MSG0 %ld|1", bp->msgnum);          /* top level citadel headers only */
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 1) {
@@ -134,14 +136,15 @@ void blogview_learn_thread_references(struct blogpost *bp)
                        else if (!strncasecmp(ChrPtr(Buf), "wefw=", 5)) {
                                StrBufCutLeft(Buf, 5);          /* trim the field name */
                                wc_printf("refs %s, ", ChrPtr(Buf));
-                               StrBufCutAt(Buf, 0, "|");       /* trim all but the first thread ref */
-                               wc_printf("topref %s, ", ChrPtr(Buf));
-                               bp->refs = HashLittle(ChrPtr(Buf), StrLength(Buf));
+                               StrBufExtract_token(r, Buf, 0, '|');
+                               wc_printf("topref %s, ", ChrPtr(r));
+                               bp->refs = HashLittle(ChrPtr(r), StrLength(r));
                        }
                }
                wc_printf("<br>\n");
        }
        FreeStrBuf(&Buf);
+       FreeStrBuf(&r);
 }