<br><br>
<div class="gmail_quote">On Wed, Aug 5, 2009 at 12:22 PM, Sasha Khapyorsky <span dir="ltr"><<a href="mailto:sashak@voltaire.com">sashak@voltaire.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="im">On 10:21 Wed 05 Aug     , Hal Rosenstock wrote:<br>><br>> Is this what you mean or am I missing your idea on how the p_lash->switches<br>> array is to be reordered ?<br><br></div>Thinking more about this I suppose that an original structure is good<br>
enough for doing what you need without intermediate buffers. It could be<br>something like this:<br><br>       qsort(index....);<br><br>       for (i = 0; i < num_switches; i++)<br>               lash->switches[index[i].index]->id = i;<br>

<div class="im"><br>       for (i = 0; i < num_switches; i++) {<br></div>               s = lash->switches[i];<br>               for (j = 0; j < s->num_links; j++)<br>                       s->links[j]->switch_id =<br>
                           lash->switches[s->links[j]->switch_id]->id;<br>       }<br><br>       for (i = 0; i < num_switches; i++) {<br>               s = lash->switches[i];<br>               while (s->id != i) {<br>
                       s1 = lash->switches[s->id];<br>                       lash->switches[s->id] = s;<br>                       s = s1;<br>               }<br>       }<br><br>Would it work?</blockquote>
<div> </div>
<div>Even if something like this works (haven't played with it yet), is it worth iterating over lash->switches array to save a memory allocation ? That seems to be what is being optimized to me. Also, couldn't this be a subsequent step in the evolution of this code ?</div>

<div> </div>
<div>-- Hal</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br><font color="#888888"><br>Sasha<br></font></blockquote></div><br>