Blog Post
luk
6 years agoBoss
JohnD ChetnaS could you please elaborate a bit more from a technical perspective on why the following might be slow (e.g. why the new FreeMarker method utils.sequence.copyOf(<sequence>) is necessary):
<#assign items = []> <#list 1..10 as x> <#assign items = items + [x]> </#list> <#--
At this point, items is a sequence of size 10,
but accessing it may be very slow. <---- why?
--> <#assign items = utils.sequence.copyOf(items)> <#-- We paid the slow cost once, but using the new items sequence should be fast -->
this is a VERY common pattern and I would be very interested in understanding why .copyOf() will make subsequent iterations faster, thanks in advance!