-
Notifications
You must be signed in to change notification settings - Fork 183
Optimize header reading #1449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize header reading #1449
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Token terminus = new Token(serialized, serializedLength, serializedLength - 2, TokenType.CRLF); | ||
Token token = new Token(serialized, serializedLength, HEADER_VERSION_BYTES_LEN, null); | ||
|
||
boolean hadStatus = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting in NatsJetStreamConstants to be able to not depend on KV in non kv code
} | ||
hasValue = true; | ||
} | ||
valueLength = hasValue ? end - start + 1 : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
holding length in a variable removes the need to calculate it repeatedly
No description provided.