Fossil SCM
Improve RSS performance for forum and technote content rendering.
Commit
a24637996d9edc69371eeae7bef1d2f2cfb46c3bbcb9c1d89cae7063b91aad3e
Parent
a88d460c5b32977…
2 files changed
+9
-25
+8
-4
+9
-25
| --- src/rss.c | ||
| +++ src/rss.c | ||
| @@ -21,25 +21,11 @@ | ||
| 21 | 21 | #include <time.h> |
| 22 | 22 | #include "rss.h" |
| 23 | 23 | #include <assert.h> |
| 24 | 24 | |
| 25 | 25 | void forum_render_to_html(struct Blob*, const char*, const char*); |
| 26 | -void technote_render_to_html(struct Blob*, int); | |
| 27 | - | |
| 28 | -/* | |
| 29 | -** Return the technote id (event- tag suffix) for rid, or NULL. | |
| 30 | -** Caller must free the returned string. | |
| 31 | -*/ | |
| 32 | -static char *rss_technote_id(int rid){ | |
| 33 | - return db_text(0, | |
| 34 | - "SELECT substr(tagname,7) FROM tag, tagxref" | |
| 35 | - " WHERE tag.tagid=tagxref.tagid" | |
| 36 | - " AND tagxref.rid=%d" | |
| 37 | - " AND tagname GLOB 'event-*'", | |
| 38 | - rid | |
| 39 | - ); | |
| 40 | -} | |
| 26 | +char *technote_render_to_html(struct Blob*, int); | |
| 41 | 27 | |
| 42 | 28 | /* |
| 43 | 29 | ** Append text to pOut, escaping any CDATA terminators. |
| 44 | 30 | */ |
| 45 | 31 | static void rss_cdata_append(Blob *pOut, const char *zIn, int nIn){ |
| @@ -282,13 +268,13 @@ | ||
| 282 | 268 | blob_zero(&bSQL); |
| 283 | 269 | blob_append_sql( &bSQL, "%s", zSQL1/*safe-for-%s*/ ); |
| 284 | 270 | if( bHasForum ){ |
| 285 | 271 | blob_append_sql(&bSQL, |
| 286 | 272 | " AND (event.type!='f' OR event.objid IN (" |
| 287 | - "SELECT fpid FROM forumpost AS f " | |
| 288 | - "WHERE NOT EXISTS(SELECT 1 FROM forumpost AS nx " | |
| 289 | - "WHERE nx.fprev=f.fpid)))" | |
| 273 | + "SELECT fpid FROM forumpost " | |
| 274 | + "WHERE fpid NOT IN (SELECT fprev FROM forumpost WHERE fprev IS NOT NULL)" | |
| 275 | + "))" | |
| 290 | 276 | ); |
| 291 | 277 | }else{ |
| 292 | 278 | blob_append_sql(&bSQL, " AND event.type!='f'"); |
| 293 | 279 | } |
| 294 | 280 | |
| @@ -446,12 +432,11 @@ | ||
| 446 | 432 | blob_reset(&normalized); |
| 447 | 433 | bForumContent = 1; |
| 448 | 434 | } |
| 449 | 435 | } |
| 450 | 436 | }else if( zEType[0]=='e' ){ |
| 451 | - zTechnoteId = rss_technote_id(rid); | |
| 452 | - technote_render_to_html(&contentHtml, rid); | |
| 437 | + zTechnoteId = technote_render_to_html(&contentHtml, rid); | |
| 453 | 438 | if( blob_size(&contentHtml)>0 ){ |
| 454 | 439 | Blob normalized = BLOB_INITIALIZER; |
| 455 | 440 | rss_make_abs_links(&normalized, blob_str(&base), |
| 456 | 441 | blob_str(&top), blob_str(&contentHtml), |
| 457 | 442 | blob_size(&contentHtml)); |
| @@ -582,13 +567,13 @@ | ||
| 582 | 567 | blob_append( &bSQL, zSQL1, -1 ); |
| 583 | 568 | bHasForum = db_table_exists("repository","forumpost"); |
| 584 | 569 | if( bHasForum ){ |
| 585 | 570 | blob_append_sql(&bSQL, |
| 586 | 571 | " AND (event.type!='f' OR event.objid IN (" |
| 587 | - "SELECT fpid FROM forumpost AS f " | |
| 588 | - "WHERE NOT EXISTS(SELECT 1 FROM forumpost AS nx " | |
| 589 | - "WHERE nx.fprev=f.fpid)))" | |
| 572 | + "SELECT fpid FROM forumpost " | |
| 573 | + "WHERE fpid NOT IN (SELECT fprev FROM forumpost WHERE fprev IS NOT NULL)" | |
| 574 | + "))" | |
| 590 | 575 | ); |
| 591 | 576 | }else{ |
| 592 | 577 | blob_append_sql(&bSQL, " AND event.type!='f'"); |
| 593 | 578 | } |
| 594 | 579 | |
| @@ -721,12 +706,11 @@ | ||
| 721 | 706 | blob_reset(&normalized); |
| 722 | 707 | bForumContent = 1; |
| 723 | 708 | } |
| 724 | 709 | } |
| 725 | 710 | }else if( zEType[0]=='e' ){ |
| 726 | - zTechnoteId = rss_technote_id(rid); | |
| 727 | - technote_render_to_html(&contentHtml, rid); | |
| 711 | + zTechnoteId = technote_render_to_html(&contentHtml, rid); | |
| 728 | 712 | if( blob_size(&contentHtml)>0 ){ |
| 729 | 713 | Blob normalized = BLOB_INITIALIZER; |
| 730 | 714 | rss_make_abs_links(&normalized, blob_str(&base), |
| 731 | 715 | blob_str(&top), blob_str(&contentHtml), |
| 732 | 716 | blob_size(&contentHtml)); |
| 733 | 717 |
| --- src/rss.c | |
| +++ src/rss.c | |
| @@ -21,25 +21,11 @@ | |
| 21 | #include <time.h> |
| 22 | #include "rss.h" |
| 23 | #include <assert.h> |
| 24 | |
| 25 | void forum_render_to_html(struct Blob*, const char*, const char*); |
| 26 | void technote_render_to_html(struct Blob*, int); |
| 27 | |
| 28 | /* |
| 29 | ** Return the technote id (event- tag suffix) for rid, or NULL. |
| 30 | ** Caller must free the returned string. |
| 31 | */ |
| 32 | static char *rss_technote_id(int rid){ |
| 33 | return db_text(0, |
| 34 | "SELECT substr(tagname,7) FROM tag, tagxref" |
| 35 | " WHERE tag.tagid=tagxref.tagid" |
| 36 | " AND tagxref.rid=%d" |
| 37 | " AND tagname GLOB 'event-*'", |
| 38 | rid |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | /* |
| 43 | ** Append text to pOut, escaping any CDATA terminators. |
| 44 | */ |
| 45 | static void rss_cdata_append(Blob *pOut, const char *zIn, int nIn){ |
| @@ -282,13 +268,13 @@ | |
| 282 | blob_zero(&bSQL); |
| 283 | blob_append_sql( &bSQL, "%s", zSQL1/*safe-for-%s*/ ); |
| 284 | if( bHasForum ){ |
| 285 | blob_append_sql(&bSQL, |
| 286 | " AND (event.type!='f' OR event.objid IN (" |
| 287 | "SELECT fpid FROM forumpost AS f " |
| 288 | "WHERE NOT EXISTS(SELECT 1 FROM forumpost AS nx " |
| 289 | "WHERE nx.fprev=f.fpid)))" |
| 290 | ); |
| 291 | }else{ |
| 292 | blob_append_sql(&bSQL, " AND event.type!='f'"); |
| 293 | } |
| 294 | |
| @@ -446,12 +432,11 @@ | |
| 446 | blob_reset(&normalized); |
| 447 | bForumContent = 1; |
| 448 | } |
| 449 | } |
| 450 | }else if( zEType[0]=='e' ){ |
| 451 | zTechnoteId = rss_technote_id(rid); |
| 452 | technote_render_to_html(&contentHtml, rid); |
| 453 | if( blob_size(&contentHtml)>0 ){ |
| 454 | Blob normalized = BLOB_INITIALIZER; |
| 455 | rss_make_abs_links(&normalized, blob_str(&base), |
| 456 | blob_str(&top), blob_str(&contentHtml), |
| 457 | blob_size(&contentHtml)); |
| @@ -582,13 +567,13 @@ | |
| 582 | blob_append( &bSQL, zSQL1, -1 ); |
| 583 | bHasForum = db_table_exists("repository","forumpost"); |
| 584 | if( bHasForum ){ |
| 585 | blob_append_sql(&bSQL, |
| 586 | " AND (event.type!='f' OR event.objid IN (" |
| 587 | "SELECT fpid FROM forumpost AS f " |
| 588 | "WHERE NOT EXISTS(SELECT 1 FROM forumpost AS nx " |
| 589 | "WHERE nx.fprev=f.fpid)))" |
| 590 | ); |
| 591 | }else{ |
| 592 | blob_append_sql(&bSQL, " AND event.type!='f'"); |
| 593 | } |
| 594 | |
| @@ -721,12 +706,11 @@ | |
| 721 | blob_reset(&normalized); |
| 722 | bForumContent = 1; |
| 723 | } |
| 724 | } |
| 725 | }else if( zEType[0]=='e' ){ |
| 726 | zTechnoteId = rss_technote_id(rid); |
| 727 | technote_render_to_html(&contentHtml, rid); |
| 728 | if( blob_size(&contentHtml)>0 ){ |
| 729 | Blob normalized = BLOB_INITIALIZER; |
| 730 | rss_make_abs_links(&normalized, blob_str(&base), |
| 731 | blob_str(&top), blob_str(&contentHtml), |
| 732 | blob_size(&contentHtml)); |
| 733 |
| --- src/rss.c | |
| +++ src/rss.c | |
| @@ -21,25 +21,11 @@ | |
| 21 | #include <time.h> |
| 22 | #include "rss.h" |
| 23 | #include <assert.h> |
| 24 | |
| 25 | void forum_render_to_html(struct Blob*, const char*, const char*); |
| 26 | char *technote_render_to_html(struct Blob*, int); |
| 27 | |
| 28 | /* |
| 29 | ** Append text to pOut, escaping any CDATA terminators. |
| 30 | */ |
| 31 | static void rss_cdata_append(Blob *pOut, const char *zIn, int nIn){ |
| @@ -282,13 +268,13 @@ | |
| 268 | blob_zero(&bSQL); |
| 269 | blob_append_sql( &bSQL, "%s", zSQL1/*safe-for-%s*/ ); |
| 270 | if( bHasForum ){ |
| 271 | blob_append_sql(&bSQL, |
| 272 | " AND (event.type!='f' OR event.objid IN (" |
| 273 | "SELECT fpid FROM forumpost " |
| 274 | "WHERE fpid NOT IN (SELECT fprev FROM forumpost WHERE fprev IS NOT NULL)" |
| 275 | "))" |
| 276 | ); |
| 277 | }else{ |
| 278 | blob_append_sql(&bSQL, " AND event.type!='f'"); |
| 279 | } |
| 280 | |
| @@ -446,12 +432,11 @@ | |
| 432 | blob_reset(&normalized); |
| 433 | bForumContent = 1; |
| 434 | } |
| 435 | } |
| 436 | }else if( zEType[0]=='e' ){ |
| 437 | zTechnoteId = technote_render_to_html(&contentHtml, rid); |
| 438 | if( blob_size(&contentHtml)>0 ){ |
| 439 | Blob normalized = BLOB_INITIALIZER; |
| 440 | rss_make_abs_links(&normalized, blob_str(&base), |
| 441 | blob_str(&top), blob_str(&contentHtml), |
| 442 | blob_size(&contentHtml)); |
| @@ -582,13 +567,13 @@ | |
| 567 | blob_append( &bSQL, zSQL1, -1 ); |
| 568 | bHasForum = db_table_exists("repository","forumpost"); |
| 569 | if( bHasForum ){ |
| 570 | blob_append_sql(&bSQL, |
| 571 | " AND (event.type!='f' OR event.objid IN (" |
| 572 | "SELECT fpid FROM forumpost " |
| 573 | "WHERE fpid NOT IN (SELECT fprev FROM forumpost WHERE fprev IS NOT NULL)" |
| 574 | "))" |
| 575 | ); |
| 576 | }else{ |
| 577 | blob_append_sql(&bSQL, " AND event.type!='f'"); |
| 578 | } |
| 579 | |
| @@ -721,12 +706,11 @@ | |
| 706 | blob_reset(&normalized); |
| 707 | bForumContent = 1; |
| 708 | } |
| 709 | } |
| 710 | }else if( zEType[0]=='e' ){ |
| 711 | zTechnoteId = technote_render_to_html(&contentHtml, rid); |
| 712 | if( blob_size(&contentHtml)>0 ){ |
| 713 | Blob normalized = BLOB_INITIALIZER; |
| 714 | rss_make_abs_links(&normalized, blob_str(&base), |
| 715 | blob_str(&top), blob_str(&contentHtml), |
| 716 | blob_size(&contentHtml)); |
| 717 |
+8
-4
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -2566,11 +2566,11 @@ | ||
| 2566 | 2566 | const char *zContent, |
| 2567 | 2567 | int eDocSrc |
| 2568 | 2568 | ); |
| 2569 | 2569 | |
| 2570 | 2570 | /* Render a technote's content (rid) to HTML in an output blob. */ |
| 2571 | -void technote_render_to_html(Blob *pOut, int rid); | |
| 2571 | +char *technote_render_to_html(Blob *pOut, int rid); | |
| 2572 | 2572 | #endif |
| 2573 | 2573 | |
| 2574 | 2574 | /* |
| 2575 | 2575 | ** Show the default Section label for an associated wiki page. |
| 2576 | 2576 | */ |
| @@ -2668,18 +2668,22 @@ | ||
| 2668 | 2668 | blob_reset(&in); |
| 2669 | 2669 | } |
| 2670 | 2670 | |
| 2671 | 2671 | /* |
| 2672 | 2672 | ** Render technote content into an output blob as HTML. |
| 2673 | +** Return the technote id. The caller must free the result. | |
| 2673 | 2674 | */ |
| 2674 | -void technote_render_to_html(Blob *pOut, int rid){ | |
| 2675 | +char *technote_render_to_html(Blob *pOut, int rid){ | |
| 2675 | 2676 | Manifest *pNote; |
| 2676 | - if( pOut==0 ) return; | |
| 2677 | + char *zEventId = 0; | |
| 2678 | + if( pOut==0 ) return 0; | |
| 2677 | 2679 | pNote = manifest_get(rid, CFTYPE_EVENT, 0); |
| 2678 | - if( pNote==0 ) return; | |
| 2680 | + if( pNote==0 ) return 0; | |
| 2681 | + if( pNote->zEventId ) zEventId = mprintf("%s", pNote->zEventId); | |
| 2679 | 2682 | wiki_convert_to_html(pOut, pNote->zMimetype, pNote->zWiki, DOCSRC_WIKI); |
| 2680 | 2683 | manifest_destroy(pNote); |
| 2684 | + return zEventId; | |
| 2681 | 2685 | } |
| 2682 | 2686 | |
| 2683 | 2687 | /* |
| 2684 | 2688 | ** Check to see if there exists a wiki page with a name zPrefix/zName. |
| 2685 | 2689 | ** If there is, then render a <div class='section'>..</div> and |
| 2686 | 2690 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -2566,11 +2566,11 @@ | |
| 2566 | const char *zContent, |
| 2567 | int eDocSrc |
| 2568 | ); |
| 2569 | |
| 2570 | /* Render a technote's content (rid) to HTML in an output blob. */ |
| 2571 | void technote_render_to_html(Blob *pOut, int rid); |
| 2572 | #endif |
| 2573 | |
| 2574 | /* |
| 2575 | ** Show the default Section label for an associated wiki page. |
| 2576 | */ |
| @@ -2668,18 +2668,22 @@ | |
| 2668 | blob_reset(&in); |
| 2669 | } |
| 2670 | |
| 2671 | /* |
| 2672 | ** Render technote content into an output blob as HTML. |
| 2673 | */ |
| 2674 | void technote_render_to_html(Blob *pOut, int rid){ |
| 2675 | Manifest *pNote; |
| 2676 | if( pOut==0 ) return; |
| 2677 | pNote = manifest_get(rid, CFTYPE_EVENT, 0); |
| 2678 | if( pNote==0 ) return; |
| 2679 | wiki_convert_to_html(pOut, pNote->zMimetype, pNote->zWiki, DOCSRC_WIKI); |
| 2680 | manifest_destroy(pNote); |
| 2681 | } |
| 2682 | |
| 2683 | /* |
| 2684 | ** Check to see if there exists a wiki page with a name zPrefix/zName. |
| 2685 | ** If there is, then render a <div class='section'>..</div> and |
| 2686 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -2566,11 +2566,11 @@ | |
| 2566 | const char *zContent, |
| 2567 | int eDocSrc |
| 2568 | ); |
| 2569 | |
| 2570 | /* Render a technote's content (rid) to HTML in an output blob. */ |
| 2571 | char *technote_render_to_html(Blob *pOut, int rid); |
| 2572 | #endif |
| 2573 | |
| 2574 | /* |
| 2575 | ** Show the default Section label for an associated wiki page. |
| 2576 | */ |
| @@ -2668,18 +2668,22 @@ | |
| 2668 | blob_reset(&in); |
| 2669 | } |
| 2670 | |
| 2671 | /* |
| 2672 | ** Render technote content into an output blob as HTML. |
| 2673 | ** Return the technote id. The caller must free the result. |
| 2674 | */ |
| 2675 | char *technote_render_to_html(Blob *pOut, int rid){ |
| 2676 | Manifest *pNote; |
| 2677 | char *zEventId = 0; |
| 2678 | if( pOut==0 ) return 0; |
| 2679 | pNote = manifest_get(rid, CFTYPE_EVENT, 0); |
| 2680 | if( pNote==0 ) return 0; |
| 2681 | if( pNote->zEventId ) zEventId = mprintf("%s", pNote->zEventId); |
| 2682 | wiki_convert_to_html(pOut, pNote->zMimetype, pNote->zWiki, DOCSRC_WIKI); |
| 2683 | manifest_destroy(pNote); |
| 2684 | return zEventId; |
| 2685 | } |
| 2686 | |
| 2687 | /* |
| 2688 | ** Check to see if there exists a wiki page with a name zPrefix/zName. |
| 2689 | ** If there is, then render a <div class='section'>..</div> and |
| 2690 |