<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>
<blockquote type="cite">the main purpose of the the symbol table
is, as i understand it, to make string comparison super-fast (as
there's no need to compare each character but just a simple
address).
</blockquote>
It is only fast if both sides are `t_symbol *`, but if one side
includes a call to gensym(), it will be *slower* than a simple
strcmp()!</p>
<p>For example,</p>
<pre>flagsym == gensym("-lib")
</pre>
<p>is my all means worse than<br>
</p>
<pre>!strcmp(flag, "-lib")
</pre>
<p>
<blockquote type="cite">looking at the code i see quite a number
of places¹ where something like this is used:
</blockquote>
</p>
<p>The vast majority of the cases I've found are in settings/flag
parsing.</p>
<p>First of all, these are not the performance critical parts of Pd
and most of the strings in question are very short, anyway.</p>
<p>Secondly, for symbol comparison to make sense, you would have to
create all those symbols upfront and store them somewhere. This
would indeed pollute the symbol table and add many lines of extra
code for no real benefit.<br>
</p>
<p>
<blockquote type="cite">or should they just be replaced with
symbol comparisions?
</blockquote>
I'd say: no :-)<br>
</p>
<p>Christof<br>
</p>
<div class="moz-cite-prefix">On 11.03.2021 19:26, IOhannes m zmölnig
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:21a90cef-025c-ad8a-45fb-6b729c4c8cab@iem.at">hi all,
<br>
<br>
Pd uses a symbol-table for practically all of its string handling.
<br>
the main purpose of the the symbol table is, as i understand it,
to make string comparison super-fast (as there's no need to
compare each character but just a simple address).
<br>
<br>
now, looking at the code i see quite a number of places¹ where
something like this is used:
<br>
<br>
> strcmp(atom_getsymbolarg(i, argc, argv)->s_name,
refstring);
<br>
<br>
<br>
what is the reason for this?
<br>
is it just out of habit (because in all the other projects you
usually use strcmp())
<br>
or because this is an attempt to not pollute the symbol table
needlessly?
<br>
<br>
or am i missing something?
<br>
or should they just be replaced with symbol comparisions?
<br>
<br>
gmsadr
<br>
IOhannes
<br>
<br>
<br>
<br>
¹ i've counted about 135 of such uses (automatically; so I
certainly missed a few)
<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Pd-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Pd-dev@lists.iem.at">Pd-dev@lists.iem.at</a>
<a class="moz-txt-link-freetext" href="https://lists.puredata.info/listinfo/pd-dev">https://lists.puredata.info/listinfo/pd-dev</a>
</pre>
</blockquote>
</body>
</html>