portal entry

select a category, or use search below
(searches all categories and all time range)
Title:

StructCount vs StructIsEmpty

| View in Portal
March 06, 2019 09:40:34 PM GMT
3 Comments
<p>StructCount vs StructIsEmpty performance</p>
<p>The post <a rel="nofollow" href="https://coldfusion.adobe.com/2019/03/structcount-vs-structisempty/">StructCount vs StructIsEmpty</a> appeared first on <a rel="nofollow" href="https://coldfusion.adobe.com">ColdFusion</a>.</p>
Labels: Blog, ColdFusion, Modern CFML, 2016, 2018, blog, modern cfml

Comments:

I assume that the implementation of StructIsEmpty is the following:struct.size()==0So it’s obvious, that there is no difference in performance.
Comment by neoplay
1883 | March 08, 2019 10:46:34 AM GMT
I assume that the implementation of StructIsEmpty is the following: struct.size()==0 So it’s obvious, that there is no difference in performance.
Comment by neoplay
1882 | March 08, 2019 10:49:00 AM GMT
<a href="https://coldfusion.adobe.com/profile/neoplay">neoplay</a> Java also has the .isEmpty() method as well as .size() method. Size needs to be calculated, isEmpty() can just check for 1 key/value and then stop at that point. It may be obvious to you, but I didn't know if: it does use size() or isempty() that java's size() method calculates on the fly So the investigation was to see if calling size counts the items when called. From the timings it seems that internally the size is updated as key/values are added.
Comment by aliaspooryorik
1884 | March 08, 2019 12:30:59 PM GMT