Repository navigation
Conversation
…ring loops Same as FasterXML#1681 for WriterBasedJsonGenerator: with the standard escape table the fast scan in _writeString2, _writeSegment and _writeString(char[]) tests constants instead of loading escCodes[c]. Custom quote char, escaped slashes and CharacterEscapes keep the lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C2 does not keep the _outputTail field in a register, so the loop stored it on every character; scan with a local and write the field back once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…an loops Same change as _writeString2 for _writeStringASCII (ESCAPE_NON_ASCII / highestNonEscapedChar) and _writeStringCustom (CharacterEscapes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Member
Author
|
Folded into #1682 (commit 4284dad, results: #1682 (comment)), so closing this one. |
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.
Fixes #1776. Builds on #1682.
Change
Applies #1682's
_writeString2fix to the two non-defaultWriterBasedJsonGeneratorstring scan loops: scan with a local pointer and write_outputTailback once, instead of++_outputTailper char. C2 doesn't keep the field in a register across loop iterations, so the old loops stored it on every char._writeStringASCII(int, int): used withJsonWriteFeature.ESCAPE_NON_ASCII/highestNonEscapedChar(...)_writeStringCustom(int): used with customCharacterEscapes. ThegetEscapeSequence(c)call inside the loop has no access to generator state, so a local pointer is safe there too; no write-back is needed before the call (contrary to what I suggested in Use local pointer in non-default WriterBasedJsonGenerator string scan loops #1776).The
_writeSegment*andchar[]counterparts already use local pointers.Options
This branch is built on #1682 (head
7a7a330b3), so until #1682 is merged the diff here also shows #1682's commits. The only new commit is 4284dad. Two ways to handle it:Either is fine with me.
Testing
StringBulkCopy1680Testagainst this branch. It compares Writer output withUTF8JsonGenerator(unchanged here) underESCAPE_NON_ASCII,highestNonEscapedChar(0xFF)andJsonpCharacterEscapes, which are exactly the changed paths. Both tests pass.JMH (JDK 17, i7-8550U)
writeString(String)x 200 ASCII values per op into a no-opWriter, us/op, #1682 vs this PR:JsonpCharacterEscapesJsonpCharacterEscapesESCAPE_NON_ASCII(3 forks)ESCAPE_NON_ASCII(3 forks)No release-notes entry yet: it depends on which option is chosen and which version it lands in.
🤖 Generated with Claude Code