Channel Patch
Chris Rapier
rapier at psc.edu
Wed Aug 8 05:29:06 EST 2007
Peter Stuge wrote:
> On Tue, Aug 07, 2007 at 12:51:46PM -0400, Chris Rapier wrote:
>>> If you wanted to be tricky, you could add a precomputed skip step
>>> to the channels array that would point to the next allocated
>>> channel, allowing the loop to skip past unused channels.
>> One thing I'm not is tricky. I always end up confusing myself.
>> Mostly I just write this stuff as research projects in the hope
>> that it interests someone else enough to actual code things
>> properly :)
>
> The step optimization is really simple and still allows index
> lookups. The step works just like a pointer in the linked list.
>
> As long as individual channel entries do not need to be atomically
> inserted or removed it'll work great!
I'm going to betray my ignorance here and ask for a bit of
clarification. This isn't like a skip list but basically just a data
element that points to the next active channel. So instead of iterating
through every element of the array I'd only go to active elements by
doing something like
for (c = channels; c != NULL; c = c->skip)
{}
When a channel is added or removed I would have to iterate through the
entire array and update c->skip but that operation shouldn't happen all
that often. Is this correct?
If so, this would preserve the index lookup and eliminate unnecessary
looping, wouldn't it? In fact, its basically a linked list but
superimposed on an array, right?
Chris
More information about the openssh-unix-dev
mailing list