Changes

Jump to navigation Jump to search
26 bytes added ,  10:39, 25 April 2022
==Loop Unrolling==
 
{{Mark|Introduced with Version 9.6:}}
Loops with few iterations are ''unrolled'' by the XQuery compiler to enable further optimizations:
(: rewritten to :)
1 ! (. * 2), 2 ! (. * 2)
 
(: further rewritten to :)
1 * 2, 2 * 2
</syntaxhighlight>
The standard unroll limit is <code>5</code>. It can be adjusted via with the {{Option|UNROLLLIMIT}} option, e.g. via a pragma:
<syntaxhighlight lang="xquery">
* Simple map expressions
* Simple FLWOR expressions
* Filter expressions* [[Higher-Order Functions#fn:fold-left|fn:fold-left]], [[Higher-Order Functions#fn:fold-right|fn:fold-right]], {{Function|Higher-Order Functions|fn:fold-left1}} (third example)
Care should be taken if a higher value is selected, as memory consumption and compile time will increase.
(: equivalent queries, with identical syntax trees :)
doc('addressbook.xml')//city,
doc('addressbook.xml')/descendant-or-self::node()/child::city
(: rewritten to :)
where $t/buyer/@person = $p/@id
return $t
return <item person='"{ $p/name/text() }'">{ count($a) }</item>,
(: rewritten to :)
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu