<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Thanks! That's exactly what I was hoping.<br>
<br>
--Patrick<br>
<br>
<br>
<div class="moz-cite-prefix">On 4/13/17 1:41 AM, Rahul Muttineni
wrote:<br>
</div>
<blockquote
cite="mid:CANij+eS1-5tU6QfECmwxudP-bpk9B4RQSW+-PQqLz6qo_nPYkg@mail.gmail.com"
type="cite">
<div dir="ltr">Hi Patrick,
<div><br>
</div>
<div>Yes, this will optimise to "a nice balanced tree of
decisions with dense jump tables in the leafs" [1]. You can
check out the comments in [1] for more details.<br>
<div><br>
</div>
</div>
<div>[1] <a moz-do-not-send="true"
href="https://github.com/ghc/ghc/blob/master/compiler/cmm/CmmSwitch.hs#L37">https://github.com/ghc/ghc/blob/master/compiler/cmm/CmmSwitch.hs#L37</a></div>
<div><br>
</div>
<div>Hope that helps,</div>
<div>Rahul</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Apr 13, 2017 at 3:55 AM,
Patrick Pelletier <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:code@funwithsoftware.org" target="_blank">code@funwithsoftware.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Suppose I
am doing a pattern match on a large number of consecutive
(or mostly-consecutive) integers:<br>
<br>
foo 0 = something<br>
foo 1 = somethingElse<br>
...<br>
foo 1000 = anotherThing<br>
<br>
Will GHC optimize this to a table lookup, or is it going to
test each integer in turn? Am I better off using a Vector
or Map instead of pattern matching?<br>
<br>
Thanks,<br>
<br>
--Patrick<br>
<br>
______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a moz-do-not-send="true"
href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners"
rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/beginners</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature" data-smartmail="gmail_signature">Rahul
Muttineni</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</body>
</html>