diff options
author | Brent Smith <gnome@nextreality.net> | 2006-02-12 05:06:06 +0000 |
---|---|---|
committer | Brent Smith <bmsmith@src.gnome.org> | 2006-02-12 05:06:06 +0000 |
commit | 3d7170fe64f4777ac00fc191d58494330c38efd2 (patch) | |
tree | 39648c8882f282c7c0222af002b861edb4d743b2 | |
parent | 8e957bb8825367c729a17e3891215fe14ba0f588 (diff) | |
download | yelp-3d7170fe64f4777ac00fc191d58494330c38efd2.tar.gz |
Small speedup achieved by only reading the TOC stylesheet once small
2006-02-11 Brent Smith <gnome@nextreality.net>
* src/yelp-toc-pager.c: (toc_process_pending), (process_xslt),
(process_cleanup):
Small speedup achieved by only reading the TOC stylesheet once
* stylesheets/toc2html.xsl:
small speedups
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/yelp-toc-pager.c | 30 | ||||
-rw-r--r-- | stylesheets/toc2html.xsl | 4 |
3 files changed, 35 insertions, 7 deletions
@@ -1,5 +1,13 @@ 2006-02-11 Brent Smith <gnome@nextreality.net> + * src/yelp-toc-pager.c: (toc_process_pending), (process_xslt), + (process_cleanup): + Small speedup achieved by only reading the TOC stylesheet once + * stylesheets/toc2html.xsl: + small speedups + +2006-02-11 Brent Smith <gnome@nextreality.net> + * src/yelp-toc-pager.c: (process_info_pending): Committed a patch from Robert Harris to fix a crash. diff --git a/src/yelp-toc-pager.c b/src/yelp-toc-pager.c index 8f1da635..f607e255 100644 --- a/src/yelp-toc-pager.c +++ b/src/yelp-toc-pager.c @@ -137,6 +137,7 @@ static gboolean process_mandir_pending (YelpTocPager *pager); #ifdef ENABLE_INFO static gboolean process_info_pending (YelpTocPager *pager); #endif +static gboolean process_cleanup (YelpTocPager *pager); static void toc_add_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info); @@ -364,6 +365,7 @@ toc_process_pending (YelpTocPager *pager) process_info_pending, process_xslt, #endif + process_cleanup, NULL }; static gint process_i = 0; @@ -375,6 +377,8 @@ toc_process_pending (YelpTocPager *pager) readd = priv->pending_func(pager); + /* if the pending function returned FALSE, then we move on to + * calling the next function */ if (!readd) priv->pending_func = process_funcs[++process_i]; @@ -1322,7 +1326,12 @@ process_xslt (YelpTocPager *pager) if (!priv->toc_doc) return FALSE; - priv->stylesheet = xsltParseStylesheetFile (BAD_CAST TOC_STYLESHEET); + + /* only create and parse the stylesheet on the first call to this function */ + if (!priv->stylesheet) { + priv->stylesheet = xsltParseStylesheetFile (BAD_CAST TOC_STYLESHEET); + } + if (!priv->stylesheet) { g_set_error (&error, YELP_ERROR, YELP_ERROR_PROC, _("The table of contents could not be processed. The " @@ -1381,10 +1390,6 @@ process_xslt (YelpTocPager *pager) xmlFreeDoc (priv->toc_doc); priv->toc_doc = NULL; } - if (priv->stylesheet) { - xsltFreeStylesheet (priv->stylesheet); - priv->stylesheet = NULL; - } if (priv->transformContext) { xsltFreeTransformContext (priv->transformContext); priv->transformContext = NULL; @@ -1393,6 +1398,21 @@ process_xslt (YelpTocPager *pager) return FALSE; } +static gboolean +process_cleanup (YelpTocPager *pager) +{ + YelpTocPagerPriv *priv = pager->priv; + + /* cleanup the stylesheet used to process the toc */ + if (priv->stylesheet) { + xsltFreeStylesheet (priv->stylesheet); + priv->stylesheet = NULL; + } + + /* we only ever want to run this function once, so always return false */ + return FALSE; +} + static void toc_add_doc_info (YelpTocPager *pager, YelpDocInfo *doc_info) { diff --git a/stylesheets/toc2html.xsl b/stylesheets/toc2html.xsl index 15a81b14..184c4833 100644 --- a/stylesheets/toc2html.xsl +++ b/stylesheets/toc2html.xsl @@ -122,7 +122,7 @@ <div class="leftbar"> </div> <div class="rightbar"> - <xsl:if test="toc[.//doc] or @id = 'ManInfoHolder'"> + <xsl:if test="toc[.//doc[1]] or @id = 'ManInfoHolder'"> <div class="tocs"> <ul> <xsl:for-each select="toc[../@id = 'index' or ../@id = 'ManInfoHolder' or .//doc]"> @@ -137,7 +137,7 @@ </ul> </div> </xsl:if> - <xsl:if test="doc"> + <xsl:if test="doc[1]"> <div class="docs"> <dl> <xsl:for-each select="doc"> |