<div dir="auto"><div>What I meant is that the cost of immutability can be avoided in some cases. That's primarily a matter of low level short-circuiting, not so much of writing something new. I don't know if this can be done in Java, I know the Clojure compiler does this, and I'm not aware of XQ engines that do transient operations on persistent collections.<br><div class="gmail_extra"><br><div class="gmail_quote">Op 16 jul. 2017 23:58 schreef "Michael Kay" <<a href="mailto:mike@saxonica.com" target="_blank">mike@saxonica.com</a>>:<br type="attribution"><blockquote class="m_-4633678573692541998quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-4633678573692541998quoted-text">ce between C and Assembly is a lot smaller than between C and XQ, and I think memory management should not be taken lightly (I'm not saying you do). In OP's case, I believe keys could be discarded while memory layout remains intact.<br>
<br>
<br>
</div>As a general rule of thumb, a lower-level language performs better provided that you have the time and skills to write the code efficiently.<br>
<br>
And as a general rule of thumb, you don't.<br>
<br>
Even when you are quite convinced that you do.<br>
<br>
It's a long time since I wrote in anything as low-level as C or assembler, but if you compare XQuery and Java, the level of abstraction of the API for maps is very similar, so there is no intrinsic reason to believe one should perform better than the other. The main difference is that maps in XQuery are immutable, which means you pay a little more for some operations (like adding a new entry), and you pay a lot less for other operations (llike bulk copying).<br>
<font color="#888888"><br>
Michael Kay<br>
Saxonica</font></blockquote></div><br></div></div></div>