Skip to content

Conversation

scottf
Copy link
Contributor

@scottf scottf commented Oct 7, 2025

No description provided.

scottf added 3 commits October 7, 2025 11:23
* 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 scottf requested a review from mtmk October 7, 2025 17:04
Copy link
Member

@mtmk mtmk left a 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;
Copy link
Contributor Author

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());
Copy link
Contributor Author

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;
Copy link
Contributor Author

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;
Copy link
Contributor Author

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

@scottf scottf merged commit dfd0020 into main Oct 7, 2025
4 checks passed
@scottf scottf deleted the optimize-header-reading branch October 8, 2025 14:35
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