merlimat commented on code in PR #17948:
URL: https://github.com/apache/pulsar/pull/17948#discussion_r989353822
##########
pulsar-common/src/main/java/org/apache/pulsar/common/protocol/schema/SchemaHash.java:
##########
@@ -60,7 +68,8 @@ public static SchemaHash of(SchemaInfo schemaInfo) {
}
public static SchemaHash of(byte[] schemaBytes, SchemaType schemaType) {
- return new SchemaHash(hashFunction.hashBytes(schemaBytes), schemaType);
+ return cache.get(Pair.of(schemaBytes, schemaType),
+ schemaTypePair -> new
SchemaHash(hashFunction.hashBytes(schemaBytes), schemaType));
Review Comment:
This would creating a capturing lambda each time. We could optimize by
creating a `LoadingCache`, with its loading method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]