SplitmediaLabsLimited / xjs

XSplit JS Framework. Make plugins for XSplit Broadcaster, quickly and easily.
Other
39 stars 11 forks source link

Inefficient `static getCurrentSource` function for `Source` #216

Closed mikeybanez closed 6 years ago

mikeybanez commented 6 years ago

Source.getCurrentSource is implemented in such a way that it calls getItemList, but ends up getting only the first Item in the list. This ends up being incredibly inefficient and slow once a source gets linked over several scenes, because lots of searchVideoItem and XML parsing is done for every single linked item.

As a proposed solution, we can potentially just extract the internal itemlist property directly and short-circuit this to get the first video item, in order to get the Source instance (Item#getSource).

(Just noting here that in a future refactor where Source and Item objects are barebones ids, it will be possible to directly get srcid and wrap that in a Source object instead. No need to go through Item#getSource so we can properly parse the presetconfig in order to construct the Source instance.)