[asterisk-dev] [Code Review] Implement ast_channel_search_locked to expensive per-notify channel walk in chan_sip
thp at westhawk.co.uk
Wed Nov 5 05:00:58 CST 2008
On 4 Nov 2008, at 23:54, Brian Degenhardt wrote:
> That's what I was thinking, but I was wondering if Murf and Russell
> could comment on if that approach is adequate, or if we want to
> a hashtab of channels keyed on linkedid, and insert/remove them from
> I'm sorta partial to your way, above. While it's slower, we don't
> to worry about maintaining the separate data structure which has the
> potential to get out of sync. Especially since this code only runs if
> you care about LINKEDID_END events.
I've been so long out of the C world I'm not sure this helps, but we
had a similar problem _years_ ago and I ended up solving it with a weird
dual purpose data structure. It was (originally) a linked list the
mattered and in some cases it needed to be walked in order.
The most frequent access was a name based lookup that was independent
of sequence for which we really wanted a hashtable.
What we did was to replace the 'malloc/free' code in the linked list
It allocated a slot in a hash table (based on a hash of the name). All
list walk stuff worked exactly as before, but we added a fast
that used the hashtable. It gave us a huge speedup. The only problem
the names changed. - we had to implement that as a delete/add.
More information about the asterisk-dev