<div dir="ltr"><div>Hi all,</div><div><br></div>I'm wondering what Is most efficient when you want to make some resource available as precompiled beams. <div><br></div><div>Say for example, you have a a resource available as CSV and there is a need for a lookup on this list based on one of column. </div><div><br></div><div>I am for now transforming this list in a list of matching functions (lookup(X1) ->. V1; ... lookup(XN) -> VN.). Ie you have a CSV (simplified version):</div><div><br></div><div>    Key1; V1</div><div>    Key2; V2</div><div>    ...</div><div>    KeyN; VN  <br></div><div><br></div><div>which is transformed in the following erlang file, later compiled:</div><div><br></div><div>    lookup(Key1) -> V1;</div><div>    lookup(Key2) -> V2;</div><div>    ...</div><div>    lookup(KeyN) -> VN.</div><div><br></div><div><br></div><div>But with the new optimisations in Erlang 20/21 sharing literals I am wondering if it wouldn't be more efficient to use a maps there?</div><div><br></div><div>So the generated erlang file would be:</div><div><br></div><div>    -define(to_lookup_map, #{ Key1 => V1;</div><div>                                               Key2 => V2;</div><div>                                               ...</div><div>                                               KeyN => VN }).</div><div><br></div><div>     lookup(Key) -> maps:get(Key, ?to_lookup_map).</div><div><br></div><div><br>A maps would also have some benefit in compressing a little the info I guess.</div><div><br></div><div>Thoughts?  Beside that maybe having that ressource in a memory mapped file would be better? I believe that beams are fully loaded in RAM, aren't they?<br></div><div><br></div><div>Benoit</div><div><br></div></div>