-
Notifications
You must be signed in to change notification settings - Fork 116
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
Micro-optimizations in ContentKey + TypeMapping #6975
Conversation
} | ||
if (e.isEmpty()) { | ||
int l = e.length(); | ||
sum += l; |
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.
Since we are micro-optimizing, this statement could be moved to line 189.
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.
That would optimize for the bad case though.
if (sum > MAX_LENGTH) { | ||
throw new IllegalStateException("Key too long, max allowed length: " + MAX_LENGTH); | ||
} | ||
if (elements.size() > MAX_ELEMENTS) { |
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.
This if block could be moved to line 169: there is no point in iterating over the elements, if we know that there are too many elements.
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.
That would optimize for the bad case though.
@@ -196,7 +196,11 @@ private static StringBuilder keyToStoreKeyPrepare( | |||
// Note: the relative values of outer and inner (key elements) separators affect the correctness | |||
// of StoreKey comparisons WRT to ContentKey comparisons. The inner separator must be greater | |||
// than the outer separator because longer ContentKeys are greater than shorter ContentKeys. | |||
StringBuilder sb = new StringBuilder(); | |||
int len = 4; |
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.
Why 4?
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.
Added comment
No description provided.