roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.02k stars 204 forks source link

Optimize StringList iteration #617

Closed gavv closed 8 months ago

gavv commented 8 months ago

StringList implements dynamically extended list of C strings.

Internally, it's just a continuous array. When you append a string to the list, it is copied to the end of array.

It supports iteration via nextof() method (similar to List::nextof and Hashmap::nextof).

Currently nextof() uses strlen() to find position of next string. It would be nice to avoid strlen() call for faster iteration. We can do it by prepending string size before each string stored in list. When nextof() is called, it can lookup this size and just add it to the string pointer.

In addition, it would be nice to add prevof() method, that will return element previous to given one, or NULL for the first element.

ForeverASilver commented 8 months ago

@gavv I can work on this task

gavv commented 8 months ago

You're welcome!

gavv commented 8 months ago

Merged!