Simplity some code (#11000)

Motivation:

There was some code that could be simplified.

Modification:

Simplify code.

Result:

Code cleanup
This commit is contained in:
strugcoder 2021-02-11 15:42:01 +08:00 committed by GitHub
parent ecc12903c5
commit bb9370f2a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 18 deletions

View File

@ -69,12 +69,10 @@ public class WebSocket00FrameEncoder extends MessageToMessageEncoder<WebSocketFr
int b4 = dataLen & 0x7F;
if (b1 == 0) {
if (b2 == 0) {
if (b3 == 0) {
buf.writeByte(b4);
} else {
if (b3 != 0) {
buf.writeByte(b3 | 0x80);
buf.writeByte(b4);
}
buf.writeByte(b4);
} else {
buf.writeByte(b2 | 0x80);
buf.writeByte(b3 | 0x80);

View File

@ -507,9 +507,9 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
decodedClientId.value,
willProperties,
decodedWillTopic != null ? decodedWillTopic.value : null,
decodedWillMessage != null ? decodedWillMessage : null,
decodedWillMessage,
decodedUserName != null ? decodedUserName.value : null,
decodedPassword != null ? decodedPassword : null);
decodedPassword);
return new Result<MqttConnectPayload>(mqttConnectPayload, numberOfBytesConsumed);
}

View File

@ -47,11 +47,7 @@ public class XmlElementStart extends XmlElement {
XmlElementStart that = (XmlElementStart) o;
if (!attributes.equals(that.attributes)) {
return false;
}
return true;
return attributes.equals(that.attributes);
}
@Override

View File

@ -50,11 +50,7 @@ public class XmlEntityReference {
if (name != null ? !name.equals(that.name) : that.name != null) {
return false;
}
if (text != null ? !text.equals(that.text) : that.text != null) {
return false;
}
return true;
return text != null ? text.equals(that.text) : that.text == null;
}
@Override

View File

@ -34,7 +34,7 @@ public final class ConstantTimeUtils {
* @return {@code 0} if not equal. {@code 1} if equal.
*/
public static int equalsConstantTime(int x, int y) {
int z = -1 ^ (x ^ y);
int z = ~(x ^ y);
z &= z >> 16;
z &= z >> 8;
z &= z >> 4;
@ -59,7 +59,7 @@ public final class ConstantTimeUtils {
* @return {@code 0} if not equal. {@code 1} if equal.
*/
public static int equalsConstantTime(long x, long y) {
long z = -1L ^ (x ^ y);
long z = ~(x ^ y);
z &= z >> 32;
z &= z >> 16;
z &= z >> 8;