<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">(From memory & without firing up a
compiler to verify) ...<br>
<br>
Sets are implemented as bitmaps with one bit allocated to each
possible value of the set type (hence the limitations on the
number of possible elements in the set).<br>
<br>
So if you have<br>
type bytesset = [0..7]; // 8 possible values<br>
var a: bytesset ;<br>
begin<br>
if a in [1,4] then<br>
<br>
The set literal [1,4] ends up as a byte with the value $0A.<br>
The test "a in [1,4]" is equivalent to "(a AND $0A) <> 0".<br>
<br>
The generated code (for a set of this size) is an AND followed by
a conditional jump. Very efficient.<br>
<br>
It gets a little nastier when the possible values gets larger as
the size of the set grows (set of AnsiChar is 32 bytes; Set of
Widechar exceeds the permissible size of a set).<br>
<br>
The precise code generated by case varies between jump tables and
linear comparisons.<br>
<br>
Regards<br>
<br>
<br>
On 8/06/2016 5:27 p.m., Steve Peacocke wrote:<br>
</div>
<blockquote
cite="mid:9FFCA185-0406-4604-B89E-B092A21004A2@peacocke.net"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<div>If I remember correctly, the compiler changes both to array
anyway so you come out with exactly the same compiled code. </div>
<div id="AppleMailSignature"><br>
</div>
<div id="AppleMailSignature">Perhaps someone can confirm this or
tell me how wrong I am?<br>
<br>
Steve Peacocke
<div>+64 220 612-611</div>
<div><br>
</div>
</div>
<div><br>
On 8/06/2016, at 4:56 PM, Ross Levis <<a
moz-do-not-send="true" href="mailto:ross@stationplaylist.com"><a class="moz-txt-link-abbreviated" href="mailto:ross@stationplaylist.com">ross@stationplaylist.com</a></a>>
wrote:<br>
<br>
</div>
<blockquote type="cite">
<div>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 12 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D">I’m wondering
which is more efficient to process...<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D">if (a=1) or (a=2)
then ...<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D">or<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D">if a in [1,2]
then ...<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D">If the answer is
the first method, does it make a difference if more
numbers are checked, eg. if a in [1..3,5] then<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;color:#1F497D">Cheers.</span><span
style="font-size:12.0pt;color:#1F497D"><o:p></o:p></span></p>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div><span>_______________________________________________</span><br>
<span>NZ Borland Developers Group - Delphi mailing list</span><br>
<span>Post: <a moz-do-not-send="true"
href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a></span><br>
<span>Admin: <a moz-do-not-send="true"
href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a></span><br>
<span>Unsubscribe: send an email to <a moz-do-not-send="true"
href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.net.nz</a>
with Subject: unsubscribe</span></div>
</blockquote>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: <a class="moz-txt-link-abbreviated" href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a>
Admin: <a class="moz-txt-link-freetext" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a>
Unsubscribe: send an email to <a class="moz-txt-link-abbreviated" href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe</pre>
</blockquote>
<p><br>
</p>
</body>
</html>