VirtualBox

Changeset 53924 in vbox


Ignore:
Timestamp:
Jan 22, 2015 3:57:45 PM (10 years ago)
Author:
vboxsync
Message:

websrv-cpp.xsl: Call xsltprocNewlineOutputHack once per interface to avoid excessive output buffer reallocs in xsltproc, use xsl:key and key() to access search all interface and enum elements. Execution time went from ca 8 seconds to less than 1 second.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/webservice/websrv-cpp.xsl

    r50117 r53924  
    4646<xsl:variable name="G_setSuppressedInterfaces"
    4747              select="//interface[@wsmap='suppress']" />
     48
     49<!-- - - - - - - - - - - - - - - - - - - - - - -
     50  Keys for more efficiently looking up of types.
     51 - - - - - - - - - - - - - - - - - - - - - - -->
     52
     53<xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
     54<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
    4855
    4956<!-- - - - - - - - - - - - - - - - - - - - - - -
     
    272279    <xsl:call-template name="emitNewline" />
    273280
    274     <xsl:for-each select="//interface[@name=$structname]/attribute">
     281    <xsl:for-each select="key('G_keyInterfacesByName', $structname)/attribute">
    275282      <xsl:if test="not(@wsmap = 'suppress')">
    276283        <xsl:value-of select="concat('        // -- ', $structname, '.', @name)" />
     
    390397      </xsl:call-template>
    391398    </xsl:when>
    392     <xsl:when test="//enum[@name=$type]">
     399    <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
    393400      <xsl:call-template name="emitTypeOrArray">
    394401        <xsl:with-param name="type" select="concat($type, '_T ')"/>
     
    406413      </xsl:choose>
    407414    </xsl:when>
    408     <xsl:when test="//interface[@name=$type]">
    409       <xsl:variable name="thatif" select="//interface[@name=$type]" />
     415    <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
     416      <xsl:variable name="thatif" select="key('G_keyInterfacesByName', $type)" />
    410417      <xsl:variable name="thatifname" select="$thatif/@name" />
    411418      <xsl:choose>
     
    579586          <xsl:value-of select="concat('    IUnknown *tmpObject2(tmpObject); tmpObject2->AddRef(); comcall_', $name, '[i] = tmpObject;')" />
    580587        </xsl:when>
    581         <xsl:when test="//interface[@name=$type]">
     588        <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
    582589          <xsl:value-of select="concat('    ComPtr&lt;', $type, '&gt; tmpObject;')" />
    583590          <xsl:call-template name="emitNewlineIndent8" />
     
    609616          <xsl:value-of select="concat('    comcall_', $name, '[i] = ', $structprefix, $name, '[i];')" />
    610617        </xsl:when>
    611         <xsl:when test="//enum[@name=$type]">
     618        <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
    612619          <xsl:call-template name="emitNewlineIndent8" />
    613620          <xsl:value-of select="concat('    comcall_', $name, '[i] = ', $G_funcPrefixInputEnumConverter, $type, '(', $structprefix, $name, '[i]);')" />
     
    634641          <xsl:value-of select="concat(' comcall_', $name, '(', $structprefix, $name, '.c_str())')" />
    635642        </xsl:when>
    636         <xsl:when test="//enum[@name=$type]">
     643        <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
    637644          <xsl:value-of select="concat(' comcall_', $name, ' = ', $G_funcPrefixInputEnumConverter, $type, '(', $structprefix, $name, ')')" />
    638645        </xsl:when>
     
    644651          <xsl:text>    break</xsl:text>
    645652        </xsl:when>
    646         <xsl:when test="//interface[@name=$type]">
     653        <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
    647654          <!-- the type is one of our own interfaces: then it must have a wsmap attr -->
    648           <xsl:variable name="thatif" select="//interface[@name=$type]" />
     655          <xsl:variable name="thatif" select="key('G_keyInterfacesByName', $type)" />
    649656          <xsl:variable name="wsmap" select="$thatif/@wsmap" />
    650657          <xsl:variable name="thatifname" select="$thatif/@name" />
     
    771778                        or ($type='unsigned long long')
    772779                        or ($type='result')
    773                         or (//enum[@name=$type])">
     780                        or (count(key('G_keyEnumsByName', $type)) > 0)">
    774781          <xsl:text>&amp;</xsl:text><xsl:value-of select="$varname" />
    775782        </xsl:when>
     
    900907      <xsl:value-of select="$varname" />
    901908    </xsl:when>
    902     <xsl:when test="//enum[@name=$type]">
     909    <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
    903910      <xsl:value-of select="concat($G_funcPrefixOutputEnumConverter, $type, '(', $varname, ')')" />
    904911    </xsl:when>
     
    906913      <xsl:value-of select="concat('createOrFindRefFromComPtr(idThis, g_pcszIUnknown, ', $varname, ')')" />
    907914    </xsl:when>
    908     <xsl:when test="//interface[@name=$type]">
     915    <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
    909916      <!-- the type is one of our own interfaces: then it must have a wsmap attr -->
    910       <xsl:variable name="thatif" select="//interface[@name=$type]" />
     917      <xsl:variable name="thatif" select="key('G_keyInterfacesByName', $type)" />
    911918      <xsl:variable name="wsmap" select="$thatif/@wsmap" />
    912919      <xsl:variable name="thatifname" select="$thatif/@name" />
     
    9931000      <xsl:variable name="gluetypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename" />
    9941001      <xsl:choose>
    995         <xsl:when test="//interface[@name=$type]">
     1002        <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
    9961003          <xsl:value-of select="concat('    ComPtr&lt;', $type, '&gt; tmpObject(', $varname, '[i]);')" />
    9971004        </xsl:when>
    998         <xsl:when test="//enum[@name=$type]">
     1005        <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
    9991006          <xsl:value-of select="concat('    ', $type, '_T tmpObject(', $varname, '[i]);')" />
    10001007        </xsl:when>
     
    12681275<xsl:text>
    12691276 *
    1270  ****************************************************************************/
    1271 </xsl:text>
     1277 ****************************************************************************/</xsl:text>
     1278    <xsl:call-template name="xsltprocNewlineOutputHack"/>
    12721279
    12731280    <!--
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