AntonRoskvist commented on code in PR #4023:
URL: https://github.com/apache/activemq-artemis/pull/4023#discussion_r846228548
##########
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java:
##########
@@ -196,26 +195,22 @@ public boolean
updateDeliveryCountAfterCancel(ServerConsumer consumer, MessageRe
private boolean checkCachedExistingQueues(final SimpleString address,
final String physicalName,
final boolean isTemporary) throws
Exception {
- String[] existingQueuesCache = this.existingQueuesCache;
//lazy allocation of the cache
if (existingQueuesCache == null) {
- //16 means 64 bytes with 32 bit references or 128 bytes with 64 bit
references -> 1 or 2 cache lines with common archs
existingQueuesCache = new
String[protocolManager.getOpenWireDestinationCacheSize()];
- assert (Integer.bitCount(existingQueuesCache.length) == 1) :
"openWireDestinationCacheSize must be a power of 2";
- this.existingQueuesCache = existingQueuesCache;
}
- final int hashCode = physicalName.hashCode();
- //this.existingQueuesCache.length must be power of 2
- final int mask = existingQueuesCache.length - 1;
- final int index = hashCode & mask;
+
+ final int index = Math.floorMod(physicalName.hashCode(),
existingQueuesCache.length);
Review Comment:
Yes, but since now there will only be one such calculation per new queue,
(plus new ones if the cache is full) I figure that might be cheaper overall
anyway? I changed it because this method has a lower risk of creating identical
hashes for different values (from my testing at least)...
--
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]