Conversation
* Match bytes to known values for less string allocation
* Match bytes to known values for less string allocation
* Match bytes to known values for less string allocation
scottf
commented
Oct 7, 2025
| Token terminus = new Token(serialized, serializedLength, serializedLength - 2, TokenType.CRLF); | ||
| Token token = new Token(serialized, serializedLength, HEADER_VERSION_BYTES_LEN, null); | ||
|
|
||
| boolean hadStatus = false; |
Contributor
Author
There was a problem hiding this comment.
variable was never used in the initHeader function that it was passed to and there are no other uses, so it was removed.
| headers = new Headers(); | ||
| } | ||
| headers.add(tKey.getValue(), tVal.getValue()); | ||
| headers.add(tKey.getValueCheckKnownKeys(), tVal.getValue()); |
Contributor
Author
There was a problem hiding this comment.
use the new function to get the key, checking against known keys.
| public static final String KV_SUBJECT_PREFIX = "$KV."; | ||
| public static final String KV_SUBJECT_SUFFIX = ".>"; | ||
| public static final String KV_OPERATION_HEADER_KEY = "KV-Operation"; | ||
| public static final String KV_OPERATION_HEADER_KEY = NatsJetStreamConstants.KV_OPERATION_HEADER_KEY; |
Contributor
Author
There was a problem hiding this comment.
Putting in NatsJetStreamConstants to be able to not depend on KV in non kv code
| } | ||
| hasValue = true; | ||
| } | ||
| valueLength = hasValue ? end - start + 1 : 0; |
Contributor
Author
There was a problem hiding this comment.
holding length in a variable removes the need to calculate it repeatedly
mtmk
reviewed
Oct 7, 2025
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.
No description provided.