mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Code cleanups
This commit is contained in:
@@ -49,7 +49,7 @@ final class JsonUtf8Writer extends JsonWriter {
|
||||
static {
|
||||
REPLACEMENT_CHARS = new String[128];
|
||||
for (int i = 0; i <= 0x1f; i++) {
|
||||
REPLACEMENT_CHARS[i] = String.format("\\u%04x", (int) i);
|
||||
REPLACEMENT_CHARS[i] = String.format("\\u%04x", i);
|
||||
}
|
||||
REPLACEMENT_CHARS['"'] = "\\\"";
|
||||
REPLACEMENT_CHARS['\\'] = "\\\\";
|
||||
|
@@ -43,7 +43,7 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
||||
}
|
||||
};
|
||||
|
||||
Comparator<? super K> comparator;
|
||||
final Comparator<? super K> comparator;
|
||||
Node<K, V>[] table;
|
||||
final Node<K, V> header;
|
||||
int size = 0;
|
||||
@@ -346,13 +346,11 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
||||
int rightLeftHeight = rightLeft != null ? rightLeft.height : 0;
|
||||
|
||||
int rightDelta = rightLeftHeight - rightRightHeight;
|
||||
if (rightDelta == -1 || (rightDelta == 0 && !insert)) {
|
||||
rotateLeft(node); // AVL right right
|
||||
} else {
|
||||
if (rightDelta != -1 && (rightDelta != 0 || insert)) {
|
||||
assert (rightDelta == 1);
|
||||
rotateRight(right); // AVL right left
|
||||
rotateLeft(node);
|
||||
}
|
||||
rotateLeft(node); // AVL right right
|
||||
if (insert) {
|
||||
break; // no further rotations will be necessary
|
||||
}
|
||||
@@ -364,13 +362,11 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
||||
int leftLeftHeight = leftLeft != null ? leftLeft.height : 0;
|
||||
|
||||
int leftDelta = leftLeftHeight - leftRightHeight;
|
||||
if (leftDelta == 1 || (leftDelta == 0 && !insert)) {
|
||||
rotateRight(node); // AVL left left
|
||||
} else {
|
||||
if (leftDelta != 1 && (leftDelta != 0 || insert)) {
|
||||
assert (leftDelta == -1);
|
||||
rotateLeft(left); // AVL left right
|
||||
rotateRight(node);
|
||||
}
|
||||
rotateRight(node); // AVL left left
|
||||
if (insert) {
|
||||
break; // no further rotations will be necessary
|
||||
}
|
||||
|
@@ -184,7 +184,7 @@ public final class Moshi {
|
||||
@CheckReturnValue
|
||||
public Moshi.Builder newBuilder() {
|
||||
Builder result = new Builder();
|
||||
for (int i = 0, limit = lastOffset; i < limit; i++) {
|
||||
for (int i = 0; i < lastOffset; i++) {
|
||||
result.add(factories.get(i));
|
||||
}
|
||||
for (int i = lastOffset, limit = factories.size() - BUILT_IN_FACTORIES.size(); i < limit; i++) {
|
||||
|
@@ -61,7 +61,7 @@ class KotlinExtensionsTest {
|
||||
fun addAdapterInferred() {
|
||||
// An adapter that always returns -1
|
||||
val customIntdapter = object : JsonAdapter<Int>() {
|
||||
override fun fromJson(reader: JsonReader): Int? {
|
||||
override fun fromJson(reader: JsonReader): Int {
|
||||
reader.skipValue()
|
||||
return -1
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class KotlinExtensionsTest {
|
||||
fun addAdapterInferred_parameterized() {
|
||||
// An adapter that always returns listOf(-1)
|
||||
val customIntListAdapter = object : JsonAdapter<List<Int>>() {
|
||||
override fun fromJson(reader: JsonReader): List<Int>? {
|
||||
override fun fromJson(reader: JsonReader): List<Int> {
|
||||
reader.skipValue()
|
||||
return listOf(-1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user