Skip to content

Improve json recursive performance #977

Closed
@ParticleCore

Description

@ParticleCore

Currently there are a few operations that take a performance hit that is noticeable due to brief UI lockups, these mostly occur when the comment section is loading, which can contain a significant amount of data, and deep hierarchy.

In multiple sections of the extension the root path is being passed arbitrarily, meaning the recursive function has to traverse the entire json tree even when it might not be of interest for the function using it.

Ideally this should be substituted by a specific prior root path check to ensure the data is of interest of the function, for example:

const canProceed = data => data?.["contents"]
|| data?.["videoDetails"]
|| data?.["items"]
|| data?.["onResponseReceivedActions"]
|| data?.["onResponseReceivedEndpoints"]
|| data?.["onResponseReceivedCommands"];

Problem is this might introduce bugs because there might be multiple paths for the same root and all must be covered, for example a multi-path deep node:

const items = itemContainer[i]?.["itemSectionRenderer"]?.["contents"]
|| itemContainer[i]?.["shelfRenderer"]?.["content"]?.["verticalListRenderer"]?.["items"];

However, the performance impact is noticeable so this must be improved in one way or another.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions