<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Mar 30, 2016 at 3:16 AM Richard A. O'Keefe <<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I notice a lot of lines like<br>
<br>
,"0001" => { "0", "", ""}<br>
,"0002" => { "0", "", ""}<br>
,"0003" => { "0", "", ""}<br>
,"0004" => { "0", "", ""}<br>
,"0005" => { "0", "", ""}<br>
,"0006" => { "0", "", ""}<br>
,"0007" => { "0", "", ""}<br>
<br>
I just wonder whether factoring {"0","",""} out<br>
would help at all.<br>
<br>
I also notice that the lines are all<br>
"<hex>" => {"<dec>", "<stuff>", "<hex>"}<br>
and wonder whether having three maps<br>
<int> => "<dec>"<br>
<int> => "<stuff>"<br>
<int> => "<hex>"<br></blockquote><div><br></div><div><span><div style="color:rgb(0,0,0)">So I changed the code to use integers everywhere. It makes the processing a lot faster:</div><div style="color:rgb(0,0,0)"><a href="https://github.com/benoitc/erlang-idna/commit/a40fedb1ac2933a4d668b4813bf2cfab408ef6a4" style="outline:transparent solid 1px">https://github.com/benoitc/erlang-idna/commit/a40fedb1ac2933a4d668b4813bf2cfab408ef6a4</a></div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)">For now the code is creating one module with pattern matching and still has the tuple. Since the size of the file is smaller, it compile a little faster and use less memory.</div></span><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
and then<br>
lookup(Codepoint) -><br>
N = list_to_integer(Codepoint, 16),<br>
A = maps:get(N, ?BY_CODE_TO_DEC, false),<br>
B = maps:get(N, ?BY_CODE_TO_STUFF, false),<br>
C = maps:get(N, ?BY_CODE_TO_HEX, false),<br>
if A == false -> false<br>
; true -> {A, B, C}<br>
end.<br>
might give the compiler less trouble.<br>
<br>
I mean, it seems a bit odd to do<br>
<br>
lookup(Codepoint) -><br>
idna_unicode_data:lookup(hex(Codepoint)).<br>
<br>
when you could do<br>
<br>
lookup(Codepoint) -><br>
idna_unicode_data:lookup(Codepoint).<br>
<br>
In fact, since different functions in idna_unicode.erl<br>
are interested in different bits of the triples, I<br>
don't understand why these weren't separate maps to<br>
begin with.<br>
<br></blockquote><div><br></div><div>Do you mean having different functions in the same module using a map each? What is the cost of using a map compared to use function pattern-matching if the code is called by different processes?</div><div><br></div><div>- benoit</div></div></div>