VirtualBox

Ignore:
Timestamp:
Jan 23, 2015 2:49:51 AM (10 years ago)
Author:
vboxsync
Message:

genjifaces.xsl: A couple of optimizations, reducing execution time to near a few 100 milliseconds.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/java/tools/genjifaces.xsl

    r46478 r53943  
    3333<xsl:variable name="G_xsltFilename" select="'genjifaces.xsl'" />
    3434
     35
     36<!-- - - - - - - - - - - - - - - - - - - - - - -
     37  Keys for more efficiently looking up of types.
     38- - - - - - - - - - - - - - - - - - - - - - -->
     39<xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
     40<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
     41
     42<!--
     43     xsltprocNewlineOutputHack - emits a single new line.
     44
     45     Hack Alert! This template helps xsltproc split up the output text elements
     46                 and avoid reallocating them into the MB range. Calls to this
     47                 template is made occationally while generating larger output
     48                 file.  It's not necessary for small stuff like header.
     49
     50                 The trick we're playing on xsltproc has to do with CDATA
     51                 and/or the escape setting of the xsl:text element.  It forces
     52                 xsltproc to allocate a new output element, thus preventing
     53                 things from growing out of proportions and slowing us down.
     54
     55                 This was successfully employed to reduce a 18+ seconds run to
     56                 around one second (possibly less due to kmk overhead).
     57 -->
     58<xsl:template name="xsltprocNewlineOutputHack">
     59    <xsl:text disable-output-escaping="yes"><![CDATA[
     60]]></xsl:text>
     61</xsl:template>
     62
    3563<xsl:template name="uppercase">
    3664  <xsl:param name="str" select="."/>
     
    6896  <xsl:param name="name" />
    6997  <xsl:text>/**
    70  *  Copyright (C) 2010-2013 Oracle Corporation
     98 *  Copyright (C) 2010-2015 Oracle Corporation
    7199 *
    72100 *  This file is part of VirtualBox Open Source Edition (OSE), as
     
    103131<xsl:template name="endFile">
    104132 <xsl:param name="file" />
    105  <xsl:value-of select="concat('&#10;// ##### ENDFILE &quot;', $file, '&quot;&#10;&#10;')" />
     133 <xsl:value-of select="concat('&#10;// ##### ENDFILE &quot;', $file, '&quot;&#10;')" />
     134 <xsl:call-template name="xsltprocNewlineOutputHack"/>
    106135</xsl:template>
    107136
     
    371400    </xsl:when>
    372401
    373     <xsl:when test="//interface[@name=$type]">
     402    <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
    374403      <xsl:value-of select="$type" />
    375404    </xsl:when>
    376405
    377     <xsl:when test="//enum[@name=$type]">
     406    <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
    378407      <xsl:value-of select="'long'" />
    379408    </xsl:when>
     
    395424  </xsl:call-template>
    396425
    397   <xsl:variable name="extendsidl" select="//interface[@name=$ifname]/@extends" />
     426  <xsl:variable name="extendsidl" select="key('G_keyInterfacesByName', $ifname)/@extends" />
    398427
    399428  <xsl:variable name="extends">
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette