[erlang-questions] pre-load large data files when the application start
Richard A. O'Keefe
ok@REDACTED
Wed Mar 30 03:16:36 CEST 2016
I notice a lot of lines like
,"0001" => { "0", "", ""}
,"0002" => { "0", "", ""}
,"0003" => { "0", "", ""}
,"0004" => { "0", "", ""}
,"0005" => { "0", "", ""}
,"0006" => { "0", "", ""}
,"0007" => { "0", "", ""}
I just wonder whether factoring {"0","",""} out
would help at all.
I also notice that the lines are all
"<hex>" => {"<dec>", "<stuff>", "<hex>"}
and wonder whether having three maps
<int> => "<dec>"
<int> => "<stuff>"
<int> => "<hex>"
and then
lookup(Codepoint) ->
N = list_to_integer(Codepoint, 16),
A = maps:get(N, ?BY_CODE_TO_DEC, false),
B = maps:get(N, ?BY_CODE_TO_STUFF, false),
C = maps:get(N, ?BY_CODE_TO_HEX, false),
if A == false -> false
; true -> {A, B, C}
end.
might give the compiler less trouble.
I mean, it seems a bit odd to do
lookup(Codepoint) ->
idna_unicode_data:lookup(hex(Codepoint)).
when you could do
lookup(Codepoint) ->
idna_unicode_data:lookup(Codepoint).
In fact, since different functions in idna_unicode.erl
are interested in different bits of the triples, I
don't understand why these weren't separate maps to
begin with.
More information about the erlang-questions
mailing list