From 16ab6e4cedbaf29b25ef49261a6fb1babdcbe201 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Wed, 9 May 2007 15:15:58 +0000 Subject: Merged revisions 536480 via svnmerge from https://svn.apache.org/repos/asf/incubator/qpid/branches/M2 ........ r536480 | rgodfrey | 2007-05-09 11:24:13 +0100 (Wed, 09 May 2007) | 1 line QPID-482 : Small performance enhancements ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@536560 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/framing/AMQShortString.java | 7 +- .../qpid/framing/BasicContentHeaderProperties.java | 138 ++++++++++++--------- .../org/apache/qpid/framing/EncodingUtils.java | 5 +- 3 files changed, 86 insertions(+), 64 deletions(-) (limited to 'java/common/src') diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java b/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java index f2492585bc..3f6ef73781 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java +++ b/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java @@ -15,12 +15,14 @@ public final class AMQShortString implements CharSequence, Comparable 0) + if ((_propertyFlags & (CONTENT_TYPE_MASK)) > 0) { size += EncodingUtils.encodedShortStringLength(_contentType); } - if ((_propertyFlags & (1 << 14)) > 0) + if ((_propertyFlags & ENCONDING_MASK) > 0) { size += EncodingUtils.encodedShortStringLength(_encoding); } - if ((_propertyFlags & (1 << 13)) > 0) + if ((_propertyFlags & HEADERS_MASK) > 0) { size += EncodingUtils.encodedFieldTableLength(_headers); } - if ((_propertyFlags & (1 << 12)) > 0) + if ((_propertyFlags & DELIVERY_MODE_MASK) > 0) { size += 1; } - if ((_propertyFlags & (1 << 11)) > 0) + if ((_propertyFlags & PROPRITY_MASK) > 0) { size += 1; } - if ((_propertyFlags & (1 << 10)) > 0) + if ((_propertyFlags & CORRELATION_ID_MASK) > 0) { size += EncodingUtils.encodedShortStringLength(_correlationId); } - if ((_propertyFlags & (1 << 9)) > 0) + if ((_propertyFlags & REPLY_TO_MASK) > 0) { size += EncodingUtils.encodedShortStringLength(_replyTo); } - if ((_propertyFlags & (1 << 8)) > 0) + if ((_propertyFlags & EXPIRATION_MASK) > 0) { if(_expiration == 0L) { @@ -137,27 +151,27 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti size += EncodingUtils.encodedShortStringLength(_expiration); } } - if ((_propertyFlags & (1 << 7)) > 0) + if ((_propertyFlags & MESSAGE_ID_MASK) > 0) { size += EncodingUtils.encodedShortStringLength(_messageId); } - if ((_propertyFlags & (1 << 6)) > 0) + if ((_propertyFlags & TIMESTAMP_MASK) > 0) { size += 8; } - if ((_propertyFlags & (1 << 5)) > 0) + if ((_propertyFlags & TYPE_MASK) > 0) { size += EncodingUtils.encodedShortStringLength(_type); } - if ((_propertyFlags & (1 << 4)) > 0) + if ((_propertyFlags & USER_ID_MASK) > 0) { size += EncodingUtils.encodedShortStringLength(_userId); } - if ((_propertyFlags & (1 << 3)) > 0) + if ((_propertyFlags & APPLICATION_ID_MASK) > 0) { size += EncodingUtils.encodedShortStringLength(_appId); } - if ((_propertyFlags & (1 << 2)) > 0) + if ((_propertyFlags & CLUSTER_ID_MASK) > 0) { size += EncodingUtils.encodedShortStringLength(_clusterId); } @@ -193,35 +207,35 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti } else { - if ((_propertyFlags & (1 << 15)) > 0) + if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0) { EncodingUtils.writeShortStringBytes(buffer, _contentType); } - if ((_propertyFlags & (1 << 14)) > 0) + if ((_propertyFlags & ENCONDING_MASK) != 0) { EncodingUtils.writeShortStringBytes(buffer, _encoding); } - if ((_propertyFlags & (1 << 13)) > 0) + if ((_propertyFlags & HEADERS_MASK) != 0) { EncodingUtils.writeFieldTableBytes(buffer, _headers); } - if ((_propertyFlags & (1 << 12)) > 0) + if ((_propertyFlags & DELIVERY_MODE_MASK) != 0) { buffer.put(_deliveryMode); } - if ((_propertyFlags & (1 << 11)) > 0) + if ((_propertyFlags & PROPRITY_MASK) != 0) { buffer.put(_priority); } - if ((_propertyFlags & (1 << 10)) > 0) + if ((_propertyFlags & CORRELATION_ID_MASK) != 0) { EncodingUtils.writeShortStringBytes(buffer, _correlationId); } - if ((_propertyFlags & (1 << 9)) > 0) + if ((_propertyFlags & REPLY_TO_MASK) != 0) { EncodingUtils.writeShortStringBytes(buffer, _replyTo); } - if ((_propertyFlags & (1 << 8)) > 0) + if ((_propertyFlags & EXPIRATION_MASK) != 0) { if(_expiration == 0L) { @@ -232,27 +246,27 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti EncodingUtils.writeShortStringBytes(buffer, String.valueOf(_expiration)); } } - if ((_propertyFlags & (1 << 7)) > 0) + if ((_propertyFlags & MESSAGE_ID_MASK) != 0) { EncodingUtils.writeShortStringBytes(buffer, _messageId); } - if ((_propertyFlags & (1 << 6)) > 0) + if ((_propertyFlags & TIMESTAMP_MASK) != 0) { EncodingUtils.writeTimestamp(buffer, _timestamp); } - if ((_propertyFlags & (1 << 5)) > 0) + if ((_propertyFlags & TYPE_MASK) != 0) { EncodingUtils.writeShortStringBytes(buffer, _type); } - if ((_propertyFlags & (1 << 4)) > 0) + if ((_propertyFlags & USER_ID_MASK) != 0) { EncodingUtils.writeShortStringBytes(buffer, _userId); } - if ((_propertyFlags & (1 << 3)) > 0) + if ((_propertyFlags & APPLICATION_ID_MASK) != 0) { EncodingUtils.writeShortStringBytes(buffer, _appId); } - if ((_propertyFlags & (1 << 2)) > 0) + if ((_propertyFlags & CLUSTER_ID_MASK) != 0) { EncodingUtils.writeShortStringBytes(buffer, _clusterId); } @@ -282,59 +296,59 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti int pos = buffer.position(); try { - if ((_propertyFlags & (1 << 15)) > 0) + if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0) { _contentType = EncodingUtils.readAMQShortString(buffer); } - if ((_propertyFlags & (1 << 14)) > 0) + if ((_propertyFlags & ENCONDING_MASK) != 0) { _encoding = EncodingUtils.readAMQShortString(buffer); } - if ((_propertyFlags & (1 << 13)) > 0) + if ((_propertyFlags & HEADERS_MASK) != 0) { _headers = EncodingUtils.readFieldTable(buffer); } - if ((_propertyFlags & (1 << 12)) > 0) + if ((_propertyFlags & DELIVERY_MODE_MASK) != 0) { _deliveryMode = buffer.get(); } - if ((_propertyFlags & (1 << 11)) > 0) + if ((_propertyFlags & PROPRITY_MASK) != 0) { _priority = buffer.get(); } - if ((_propertyFlags & (1 << 10)) > 0) + if ((_propertyFlags & CORRELATION_ID_MASK) != 0) { _correlationId = EncodingUtils.readAMQShortString(buffer); } - if ((_propertyFlags & (1 << 9)) > 0) + if ((_propertyFlags & REPLY_TO_MASK) != 0) { _replyTo = EncodingUtils.readAMQShortString(buffer); } - if ((_propertyFlags & (1 << 8)) > 0) + if ((_propertyFlags & EXPIRATION_MASK) != 0) { _expiration = EncodingUtils.readLongAsShortString(buffer); } - if ((_propertyFlags & (1 << 7)) > 0) + if ((_propertyFlags & MESSAGE_ID_MASK) != 0) { _messageId = EncodingUtils.readAMQShortString(buffer); } - if ((_propertyFlags & (1 << 6)) > 0) + if ((_propertyFlags & TIMESTAMP_MASK) != 0) { _timestamp = EncodingUtils.readTimestamp(buffer); } - if ((_propertyFlags & (1 << 5)) > 0) + if ((_propertyFlags & TYPE_MASK) != 0) { _type = EncodingUtils.readAMQShortString(buffer); } - if ((_propertyFlags & (1 << 4)) > 0) + if ((_propertyFlags & USER_ID_MASK) != 0) { _userId = EncodingUtils.readAMQShortString(buffer); } - if ((_propertyFlags & (1 << 3)) > 0) + if ((_propertyFlags & APPLICATION_ID_MASK) != 0) { _appId = EncodingUtils.readAMQShortString(buffer); } - if ((_propertyFlags & (1 << 2)) > 0) + if ((_propertyFlags & CLUSTER_ID_MASK) != 0) { _clusterId = EncodingUtils.readAMQShortString(buffer); } @@ -362,17 +376,17 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti ByteBuffer buffer = ByteBuffer.wrap(_encodedForm); try { - if ((_propertyFlags & (1 << 15)) > 0) + if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0) { byte length = buffer.get(); buffer.skip(length); } - if ((_propertyFlags & (1 << 14)) > 0) + if ((_propertyFlags & ENCONDING_MASK) != 0) { byte length = buffer.get(); buffer.skip(length); } - if ((_propertyFlags & (1 << 13)) > 0) + if ((_propertyFlags & HEADERS_MASK) != 0) { _headers = EncodingUtils.readFieldTable(buffer); @@ -389,7 +403,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti { ByteBuffer buffer = ByteBuffer.wrap(_encodedForm); - if ((_propertyFlags & (1 << 15)) > 0) + if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0) { _contentType = EncodingUtils.readAMQShortString(buffer); } @@ -437,7 +451,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setContentType(AMQShortString contentType) { clearEncodedForm(); - _propertyFlags |= (1 << 15); + _propertyFlags |= (CONTENT_TYPE_MASK); _contentType = contentType; } @@ -462,14 +476,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setEncoding(String encoding) { clearEncodedForm(); - _propertyFlags |= (1 << 14); + _propertyFlags |= ENCONDING_MASK; _encoding = encoding == null ? null : new AMQShortString(encoding); } public void setEncoding(AMQShortString encoding) { clearEncodedForm(); - _propertyFlags |= (1 << 14); + _propertyFlags |= ENCONDING_MASK; _encoding = encoding; } @@ -489,7 +503,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setHeaders(FieldTable headers) { clearEncodedForm(); - _propertyFlags |= (1 << 13); + _propertyFlags |= HEADERS_MASK; _headers = headers; } @@ -503,7 +517,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setDeliveryMode(byte deliveryMode) { clearEncodedForm(); - _propertyFlags |= (1 << 12); + _propertyFlags |= DELIVERY_MODE_MASK; _deliveryMode = deliveryMode; } @@ -516,7 +530,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setPriority(byte priority) { clearEncodedForm(); - _propertyFlags |= (1 << 11); + _propertyFlags |= PROPRITY_MASK; _priority = priority; } @@ -540,7 +554,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setCorrelationId(AMQShortString correlationId) { clearEncodedForm(); - _propertyFlags |= (1 << 10); + _propertyFlags |= CORRELATION_ID_MASK; _correlationId = correlationId; } @@ -566,7 +580,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti { clearEncodedForm(); - _propertyFlags |= (1 << 9); + _propertyFlags |= REPLY_TO_MASK; _replyTo = replyTo; } @@ -579,7 +593,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setExpiration(long expiration) { clearEncodedForm(); - _propertyFlags |= (1 << 8); + _propertyFlags |= EXPIRATION_MASK; _expiration = expiration; } @@ -599,14 +613,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setMessageId(String messageId) { clearEncodedForm(); - _propertyFlags |= (1 << 7); + _propertyFlags |= MESSAGE_ID_MASK; _messageId = messageId == null ? null : new AMQShortString(messageId); } public void setMessageId(AMQShortString messageId) { clearEncodedForm(); - _propertyFlags |= (1 << 7); + _propertyFlags |= MESSAGE_ID_MASK; _messageId = messageId; } @@ -620,7 +634,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setTimestamp(long timestamp) { clearEncodedForm(); - _propertyFlags |= (1 << 6); + _propertyFlags |= TIMESTAMP_MASK; _timestamp = timestamp; } @@ -646,7 +660,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setType(AMQShortString type) { clearEncodedForm(); - _propertyFlags |= (1 << 5); + _propertyFlags |= TYPE_MASK; _type = type; } @@ -670,7 +684,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setUserId(AMQShortString userId) { clearEncodedForm(); - _propertyFlags |= (1 << 4); + _propertyFlags |= USER_ID_MASK; _userId = userId; } @@ -694,7 +708,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setAppId(AMQShortString appId) { clearEncodedForm(); - _propertyFlags |= (1 << 3); + _propertyFlags |= APPLICATION_ID_MASK; _appId = appId; } @@ -718,7 +732,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setClusterId(AMQShortString clusterId) { clearEncodedForm(); - _propertyFlags |= (1 << 2); + _propertyFlags |= CLUSTER_ID_MASK; _clusterId = clusterId; } diff --git a/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java b/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java index f0cdda487c..62fefdc2fc 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java +++ b/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java @@ -157,7 +157,7 @@ public class EncodingUtils } else { - return (short) (1 + s.length()); + return (1 + s.length()); } } @@ -1023,4 +1023,7 @@ public class EncodingUtils return l; } + + + } -- cgit v1.2.1