Skip to content

Skyhight173/json: add cache to improve performance#2457

Open
LegoBrainBiker wants to merge 7 commits intoTurboWarp:masterfrom
LegoBrainBiker:patch-4
Open

Skyhight173/json: add cache to improve performance#2457
LegoBrainBiker wants to merge 7 commits intoTurboWarp:masterfrom
LegoBrainBiker:patch-4

Conversation

@LegoBrainBiker
Copy link
Copy Markdown
Contributor

the json extension can be slow because it needs to parse and stringify each time a block is called. this pr adds a cache so that if the json was recently created by the project, it can be looked up without using JSON.parse.

@github-actions github-actions bot added the pr: change existing extension Pull requests that change an existing extension label Apr 9, 2026
@LegoBrainBiker
Copy link
Copy Markdown
Contributor Author

!format

@LegoBrainBiker
Copy link
Copy Markdown
Contributor Author

!format

Comment thread extensions/Skyhigh173/json.js Outdated
const objectCache = {};
function parse(string) {
return (
objectCache[string] ??
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never write code like this. clever code is bad and unreadable

Copy link
Copy Markdown
Contributor Author

@LegoBrainBiker LegoBrainBiker Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it acceptable without the timeout?

Comment thread extensions/Skyhigh173/json.js Outdated
function stringify(object) {
const string = JSON.stringify(object);
objectCache[string] = object;
setTimeout(() => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find a way to not be making a new timeout for every single string

@LegoBrainBiker
Copy link
Copy Markdown
Contributor Author

!format

DangoCat and others added 2 commits April 10, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: change existing extension Pull requests that change an existing extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants