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

Create empty subscriptions cache objects directly instead of cloning #4814

Merged

Conversation

absidue
Copy link
Member

@absidue absidue commented Mar 26, 2024

Create empty subscriptions cache objects directly instead of cloning

Pull Request Type

  • Performance improvement

Description

As the empty subscriptions cache object is so simple, we might as well just create it directly, instead of going through JSON.stringify and JSON.parse. Especially for the posts cache, the cloning made no sense, as it uses the posts property but we were cloning an object with a videos property, so each post cache entry contained an unused videos: null property.

If the cache objects get more complex in the future, we can always move the creation code into a function that returns the objects, that will still be faster than going through JSON.stringify and JSON.parse, which also create temporary strings that then need to get garbage collected.

Testing

  1. Refresh your subscriptions
  2. Leave the subscriptions page
  3. Come back to it
  4. Your cached subscriptions should show up just like before.

Desktop

  • OS: Windows
  • OS Version: 10
  • FreeTube version: 255ba91

@absidue absidue added the PR: low priority For pull requests that don't require a fast review. e.g. code cleanup label Mar 26, 2024
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) March 26, 2024 16:48
@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Mar 26, 2024
@FreeTubeBot FreeTubeBot merged commit 598d970 into FreeTubeApp:development Mar 27, 2024
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Mar 27, 2024
@absidue absidue deleted the subscriptions-cache-optimisation branch March 27, 2024 06:35
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Apr 2, 2024
* development: (72 commits)
  Add support for CommentViews in video comments (FreeTubeApp#4806)
  Add support for LockupViews on the channel podcasts tab (FreeTubeApp#4767)
  Bump youtubei.js from 9.1.0 to 9.2.0 (FreeTubeApp#4836)
  Bump swiper from 11.0.7 to 11.1.0 (FreeTubeApp#4837)
  Bump the stylelint group with 1 update (FreeTubeApp#4835)
  Bump the eslint group with 1 update (FreeTubeApp#4834)
  Bump electron from 29.1.5 to 29.1.6 (FreeTubeApp#4838)
  Translated using Weblate (Estonian)
  Fix v-observe-visibility error when playlist items are updated (FreeTubeApp#4774)
  Fix extracting the subscriber count from channel PageHeader nodes (FreeTubeApp#4804)
  Translated using Weblate (Portuguese)
  Create empty subscriptions cache objects directly instead of cloning (FreeTubeApp#4814)
  Parse compact numbers without using floating point numbers to avoid accuracy issues (FreeTubeApp#4817)
  Fix the left arrow key not working on the first button in prompts (FreeTubeApp#4816)
  Fix the web build's manifest.json file getting included in the electron build (FreeTubeApp#4815)
  Move usingElectron from computed into data (FreeTubeApp#4810)
  Stop setting node modules path now that we bundle the modules (FreeTubeApp#4809)
  Translated using Weblate (Bulgarian)
  Bump express from 4.18.1 to 4.19.2 (FreeTubeApp#4812)
  Translated using Weblate (Portuguese (Brazil))
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: low priority For pull requests that don't require a fast review. e.g. code cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants