Mention in Gson Javadoc that reusing instance can improve performance#2983
Open
Marcono1234 wants to merge 1 commit intogoogle:mainfrom
Open
Mention in Gson Javadoc that reusing instance can improve performance#2983Marcono1234 wants to merge 1 commit intogoogle:mainfrom
Gson Javadoc that reusing instance can improve performance#2983Marcono1234 wants to merge 1 commit intogoogle:mainfrom
Conversation
| * it. Gson instances are Thread-safe so you can reuse them freely across multiple threads. | ||
| * This is the main class for using Gson. Gson is typically used by first constructing a {@code | ||
| * Gson} instance and then invoking {@link #toJson(Object)} or {@link #fromJson(String, Class)} | ||
| * methods on it. {@code Gson} instances are Thread-safe so you can reuse them freely across |
Member
There was a problem hiding this comment.
Could you remove the distracting capitalization of "Thread-safe" while you are here?
eamonnmcmanus
requested changes
Mar 1, 2026
| * <p>You can create a {@code Gson} instance by invoking {@link #Gson() new Gson()} if the default | ||
| * configuration is all you need. You can also use {@link GsonBuilder} to build a {@code Gson} | ||
| * instance with various configuration options such as versioning support, pretty printing, custom | ||
| * newline, custom indent, custom {@link JsonSerializer}s, {@link JsonDeserializer}s, and {@link |
Member
There was a problem hiding this comment.
Perhaps rewrite this last bit to talk about {@link TypeAdapter}s and {@link TypeAdapterFactory}s.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up for #2863:
Extend the
GsonJavadoc to mention that type adapters are cached and reusing aGsoninstance can improve performance.(Also formats a few "Gson" mentions as
Gson, where they refer to the class and not the project.)