What's behind ${collection?size} ?
Kjeld <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
In my template there is an instruction like: ${collection?size}
I noticed that when processing this instruction, Freemarker does a 'strange'
procedure to achieve the collection size. Instead of calling
collection.size() once, it repeats a call to the following instructions, for
every element in the collection:
collection.size()
collection.size()
collection.size()
collection.get(elementIndex)
collection.size()
collection.size()
collection.size()
My collection contains 100.000 elements, so the code here above is repeated
100.000 times, that is 700.000 instruction calls to get the collection
size... :S
I can easily bypass this by providing the template processor with the
explicit collection size, but I am very curious why Freemarker doesn't just
call collection.size() once.
Cheers,
Kjeld
--
View this message in context: http://freemarker.624813.n4.nabble.com/What-s-behind-collection-size-tp2219274p2219274.html
Sent from the freemarker-user mailing list archive at Nabble.com.
------------------------------------------------------------------------------