mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove unnecessary final modifier in StandardMessageCodec.java (#178598)
## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
cc14ef5290
commit
6252afa499
@ -115,7 +115,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
* Writes an int representing a size to the specified stream. Uses an expanding code of 1 to 5
|
||||
* bytes to optimize for small values.
|
||||
*/
|
||||
protected static final void writeSize(@NonNull ByteArrayOutputStream stream, int value) {
|
||||
protected static void writeSize(@NonNull ByteArrayOutputStream stream, int value) {
|
||||
if (BuildConfig.DEBUG && 0 > value) {
|
||||
Log.e(TAG, "Attempted to write a negative size.");
|
||||
}
|
||||
@ -131,7 +131,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
}
|
||||
|
||||
/** Writes the least significant two bytes of the specified int to the specified stream. */
|
||||
protected static final void writeChar(@NonNull ByteArrayOutputStream stream, int value) {
|
||||
protected static void writeChar(@NonNull ByteArrayOutputStream stream, int value) {
|
||||
if (LITTLE_ENDIAN) {
|
||||
stream.write(value);
|
||||
stream.write(value >>> 8);
|
||||
@ -142,7 +142,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
}
|
||||
|
||||
/** Writes the specified int as 4 bytes to the specified stream. */
|
||||
protected static final void writeInt(@NonNull ByteArrayOutputStream stream, int value) {
|
||||
protected static void writeInt(@NonNull ByteArrayOutputStream stream, int value) {
|
||||
if (LITTLE_ENDIAN) {
|
||||
stream.write(value);
|
||||
stream.write(value >>> 8);
|
||||
@ -157,7 +157,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
}
|
||||
|
||||
/** Writes the specified long as 8 bytes to the specified stream. */
|
||||
protected static final void writeLong(@NonNull ByteArrayOutputStream stream, long value) {
|
||||
protected static void writeLong(@NonNull ByteArrayOutputStream stream, long value) {
|
||||
if (LITTLE_ENDIAN) {
|
||||
stream.write((byte) value);
|
||||
stream.write((byte) (value >>> 8));
|
||||
@ -180,18 +180,17 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
}
|
||||
|
||||
/** Writes the specified double as 4 bytes to the specified stream */
|
||||
protected static final void writeFloat(@NonNull ByteArrayOutputStream stream, float value) {
|
||||
protected static void writeFloat(@NonNull ByteArrayOutputStream stream, float value) {
|
||||
writeInt(stream, Float.floatToIntBits(value));
|
||||
}
|
||||
|
||||
/** Writes the specified double as 8 bytes to the specified stream. */
|
||||
protected static final void writeDouble(@NonNull ByteArrayOutputStream stream, double value) {
|
||||
protected static void writeDouble(@NonNull ByteArrayOutputStream stream, double value) {
|
||||
writeLong(stream, Double.doubleToLongBits(value));
|
||||
}
|
||||
|
||||
/** Writes the length and then the actual bytes of the specified array to the specified stream. */
|
||||
protected static final void writeBytes(
|
||||
@NonNull ByteArrayOutputStream stream, @NonNull byte[] bytes) {
|
||||
protected static void writeBytes(@NonNull ByteArrayOutputStream stream, @NonNull byte[] bytes) {
|
||||
writeSize(stream, bytes.length);
|
||||
stream.write(bytes, 0, bytes.length);
|
||||
}
|
||||
@ -201,7 +200,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
* aligned to a whole multiple of the specified alignment. An example usage with alignment = 8 is
|
||||
* to ensure doubles are word-aligned in the stream.
|
||||
*/
|
||||
protected static final void writeAlignment(@NonNull ByteArrayOutputStream stream, int alignment) {
|
||||
protected static void writeAlignment(@NonNull ByteArrayOutputStream stream, int alignment) {
|
||||
final int mod = stream.size() % alignment;
|
||||
if (mod != 0) {
|
||||
for (int i = 0; i < alignment - mod; i++) {
|
||||
@ -221,7 +220,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
if (value == null || value.equals(null)) {
|
||||
stream.write(NULL);
|
||||
} else if (value instanceof Boolean) {
|
||||
stream.write(((Boolean) value).booleanValue() ? TRUE : FALSE);
|
||||
stream.write((Boolean) value ? TRUE : FALSE);
|
||||
} else if (value instanceof Number) {
|
||||
if (value instanceof Integer || value instanceof Short || value instanceof Byte) {
|
||||
stream.write(INT);
|
||||
@ -299,7 +298,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
}
|
||||
|
||||
/** Reads an int representing a size as written by writeSize. */
|
||||
protected static final int readSize(@NonNull ByteBuffer buffer) {
|
||||
protected static int readSize(@NonNull ByteBuffer buffer) {
|
||||
if (!buffer.hasRemaining()) {
|
||||
throw new IllegalArgumentException("Message corrupted");
|
||||
}
|
||||
@ -315,7 +314,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
|
||||
/** Reads a byte array as written by writeBytes. */
|
||||
@NonNull
|
||||
protected static final byte[] readBytes(@NonNull ByteBuffer buffer) {
|
||||
protected static byte[] readBytes(@NonNull ByteBuffer buffer) {
|
||||
final int length = readSize(buffer);
|
||||
final byte[] bytes = new byte[length];
|
||||
buffer.get(bytes);
|
||||
@ -323,7 +322,7 @@ public class StandardMessageCodec implements MessageCodec<Object> {
|
||||
}
|
||||
|
||||
/** Reads alignment padding bytes as written by writeAlignment. */
|
||||
protected static final void readAlignment(@NonNull ByteBuffer buffer, int alignment) {
|
||||
protected static void readAlignment(@NonNull ByteBuffer buffer, int alignment) {
|
||||
final int mod = buffer.position() % alignment;
|
||||
if (mod != 0) {
|
||||
buffer.position(buffer.position() + alignment - mod);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user