Welcome! Please see the About page for a little more info on how this works.

+1 vote
in ClojureScript by

When I want to encode a fixes large set of strings into the code, using #{...} generates a twice as large code than (set #js [...]) which generates the set at the start. By checking the code output with no optimization, I am getting the following code for #{...}:

`my_set = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1504, ["studio",null,"etisalat",null,"mortgage",null,"xn--gecrj9c",null,"technology",null,"nl",null,"lilly",null,"wolterskluwer",null,"schmidt",null,"hisamitsu",null,"total",null,"blue",null,"aw",null,"zw",null,"properties",null,"amex",null,"linde",null,"arpa",null,"ieee",null, ... [a lot more] ...,"fairwinds",null,"lk",null,"itau",null], null), null);`

And the following code for (set #js [...]):

`my_set = cljs.core.set(["aaa","aarp","abarth","abb","abbott","abbvie", ... [a lot more] ...,"yoga","yokohama","you","youtube","yt","yun","za","zappos","zara","zero","zip","zm","zone","zuerich","zw"]);`

(which is further optimized in advanced compilation). For this list of all 1500 TLDs, the former results in 20kB of generated code in advanced mode, and the latter only takes 10kB. Why is inner PersistentArrayMap constructed? Couldn't just JS array be passed there instead?

Please log in or register to answer this question.