phy1um / ps2-homebrew-livestreams

Repo for code written during my Playstation 2 Homebrew livestreams
MIT License
47 stars 6 forks source link

Add Slot List Abstraction for Faster List Work #49

Closed phy1um closed 2 years ago

phy1um commented 2 years ago

Resolves #48

Lua lists are limited when things need to be added and removed frequently from random indices. This PR adds an API for a faster list which is backed by a C array. Allocations to the list are O(n), and removals are O(1).

The Slot List API is based on a ring-buffer, where a head scans the array for the next free "slot" when an item is added to the list. If no slots are free then pushing to the list is an error. This also means that the iteration order does not respect the order items were pushed.

The Slot API is:

This PR also cleans up how core libraries are initialized. This is the first step in what will eventually be a reshuffle of names, but for now changes in ps2init.lua preserves compatibility.

TODO