Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immutable state #81

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Immutable state #81

wants to merge 14 commits into from

Commits on Nov 4, 2022

  1. move mutable properties out of the state table

    these are properties that we don't really want to be immutable
    CogentRedTester committed Nov 4, 2022
    Configuration menu
    Copy the full SHA
    ba35d81 View commit details
    Browse the repository at this point in the history
  2. implement API.read_only function

    this will be what enforces immutability at runtime
    CogentRedTester committed Nov 4, 2022
    Configuration menu
    Copy the full SHA
    2ddce62 View commit details
    Browse the repository at this point in the history
  3. implement function to handle state changes

    This is where the magic happens. Allowing for different levels of state
    changes while ensuring any specific state reference is immutable.
    
    Not yet tested for bugs.
    CogentRedTester committed Nov 4, 2022
    Configuration menu
    Copy the full SHA
    5991c4b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    37a7d76 View commit details
    Browse the repository at this point in the history
  5. add separate update and set state functions

    This makes it much easier to make incremental changes to the current
    state.
    
    Also added a print function to maker debugging state values easier.
    CogentRedTester committed Nov 4, 2022
    Configuration menu
    Copy the full SHA
    78264e6 View commit details
    Browse the repository at this point in the history
  6. API.copy_table: now dereferences readonly table references

    The copies are not readonly.
    CogentRedTester committed Nov 4, 2022
    Configuration menu
    Copy the full SHA
    3a2d67d View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    a7d8a17 View commit details
    Browse the repository at this point in the history
  8. switch basic file browsing to use immutable states

    Only the most basic operations have been ported, there is still a LOT
    of broken functionality.
    CogentRedTester committed Nov 4, 2022
    Configuration menu
    Copy the full SHA
    5b25e8d View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2022

  1. Configuration menu
    Copy the full SHA
    5505d42 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a051677 View commit details
    Browse the repository at this point in the history
  3. fix memory leak from readonly cache

    Since the readonly tables contain a reference to the original table we
    can't make the keys weak, at least not in Lua5.1. In Lua 5.2 weakly
    keyed tables act as ephemeron tables, so they would probably work
    there. I don't have a Lua5.2 build of mpv, so I can't test, but it might
    be worth using ephemeral tables when Lua5.2 is detected.
    CogentRedTester committed Nov 5, 2022
    Configuration menu
    Copy the full SHA
    2d75f91 View commit details
    Browse the repository at this point in the history
  4. ass: use a string buffer when drawing the browser

    String manipulation is quite costly in Lua, this significantly reduces
    the number of garbage string produced and should help to speed up
    scrolling and reduce garbage collection.
    
    Reducing garbage collection is quite important since it directly impacts
    the performance of read-only tables lookups by clearing the cache.
    CogentRedTester committed Nov 5, 2022
    Configuration menu
    Copy the full SHA
    d0eb295 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    c92b3c1 View commit details
    Browse the repository at this point in the history
  6. read-only tables: store all indexed sub-tables in upvalue

    This prevents the sub-tables from being garbage collected from the cache
    until the base read-only table has been garbage collected.
    
    This should significantly reduce the number of new read-only tables that
    are created while scrolling.
    CogentRedTester committed Nov 5, 2022
    Configuration menu
    Copy the full SHA
    781ce3f View commit details
    Browse the repository at this point in the history