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

Empty JsonObject and JsonArray constants #2808

Open
MukjepScarlet opened this issue Feb 14, 2025 · 1 comment
Open

Empty JsonObject and JsonArray constants #2808

MukjepScarlet opened this issue Feb 14, 2025 · 1 comment

Comments

@MukjepScarlet
Copy link

Feature description

Creating a new complete instance every time you need an empty JsonObject or JsonArray is a waste of memory. (creating LinkedTreeMap and ArrayList with default size)

public static final JsonObject EMPTY
public static final JsonArray EMPTY

They are immutable and always constant. So we don't even need to include any Map or List in them.

@eamonnmcmanus
Copy link
Member

I'm not sure about this. Do you see a lot of use for them? I'm a little concerned that JsonObject and JsonArray have always been mutable, and if we suddenly introduce immutable variants they may interact poorly with existing code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants