Skip to content

Mention in Gson Javadoc that reusing instance can improve performance#2983

Open
Marcono1234 wants to merge 1 commit intogoogle:mainfrom
Marcono1234:marcono1234/Gson-cache-doc
Open

Mention in Gson Javadoc that reusing instance can improve performance#2983
Marcono1234 wants to merge 1 commit intogoogle:mainfrom
Marcono1234:marcono1234/Gson-cache-doc

Conversation

@Marcono1234
Copy link
Contributor

Follow-up for #2863:
Extend the Gson Javadoc to mention that type adapters are cached and reusing a Gson instance can improve performance.

(Also formats a few "Gson" mentions as Gson, where they refer to the class and not the project.)

* 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
Copy link
Member

Choose a reason for hiding this comment

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

Could you remove the distracting capitalization of "Thread-safe" while you are here?

* <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
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps rewrite this last bit to talk about {@link TypeAdapter}s and {@link TypeAdapterFactory}s.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants