Skip to content

Optimize Java JsonFormat string printing path.#27838

Draft
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_927246964
Draft

Optimize Java JsonFormat string printing path.#27838
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_927246964

Conversation

@copybara-service
Copy link
Copy Markdown

Optimize Java JsonFormat string printing path.

  • Use a lookup table for the replacement characters in the ascii range (which is all of the characters that gson escapes except for exactly 2).

  • Stream the escapes out ourselves instead of going through gson.toJson(val.toString()) which goes through a lot of heavy gson machinery and makes several copies of the string.

We exactly match the choices that gson made for escapes here to make this an implementation detail change with no observable difference.

- Use a lookup table for the replacement characters in the ascii range (which is all of the characters that gson escapes except for exactly 2).

- Stream the escapes out ourselves instead of going through gson.toJson(val.toString()) which goes through a lot of heavy gson machinery and makes several copies of the string.

We exactly match the choices that gson made for escapes here to make this an implementation detail change with no observable difference.

PiperOrigin-RevId: 927246964
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.

1 participant