Skip to content

Commit 8982808

Browse files
committed
Reorganise code to separate out static methods.
1 parent f120234 commit 8982808

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/main/java/org/truffleruby/core/array/library/ArrayStoreLibrary.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,35 @@ public static LibraryFactory<ArrayStoreLibrary> getFactory() {
4242
return FACTORY;
4343
}
4444

45+
public static Object initialStorage(boolean shared) {
46+
if (shared) {
47+
return SHARED_INITIAL_STORE;
48+
} else {
49+
return INITIAL_STORE;
50+
}
51+
}
52+
53+
public static ArrayAllocator initialAllocator(boolean shared) {
54+
if (shared) {
55+
return SHARED_INITIAL_ALLOCATOR;
56+
} else {
57+
return INITIAL_ALLOCATOR;
58+
}
59+
}
60+
61+
/** Return an allocator for storage that can hold {@code value}. */
62+
public static ArrayAllocator allocatorForValue(Object value) {
63+
if (value instanceof Integer) {
64+
return IntegerArrayStore.INTEGER_ARRAY_ALLOCATOR;
65+
} else if (value instanceof Long) {
66+
return LongArrayStore.LONG_ARRAY_ALLOCATOR;
67+
} else if (value instanceof Double) {
68+
return DoubleArrayStore.DOUBLE_ARRAY_ALLOCATOR;
69+
} else {
70+
return ObjectArrayStore.OBJECT_ARRAY_ALLOCATOR;
71+
}
72+
}
73+
4574
/** Read the value from {@code index} of {@code store}. */
4675
public abstract Object read(Object store, int index);
4776

@@ -86,22 +115,6 @@ public Object initialStore(Object store) {
86115
return INITIAL_STORE;
87116
}
88117

89-
public static Object initialStorage(boolean shared) {
90-
if (shared) {
91-
return SHARED_INITIAL_STORE;
92-
} else {
93-
return INITIAL_STORE;
94-
}
95-
}
96-
97-
public static ArrayAllocator initialAllocator(boolean shared) {
98-
if (shared) {
99-
return SHARED_INITIAL_ALLOCATOR;
100-
} else {
101-
return INITIAL_ALLOCATOR;
102-
}
103-
}
104-
105118
/** Return whether {@code store} and {@code other} share the same underlying array storage. */
106119
public abstract boolean isSameStorage(Object store, Object other);
107120

@@ -218,19 +231,6 @@ public ArrayAllocator unsharedAllocator(Object store) {
218231
/** Return whether the {@code store}'s default value is {@code value}. */
219232
public abstract boolean isDefaultValue(Object store, Object value);
220233

221-
/** Return an allocator for storage that can hold {@code value}. */
222-
public static ArrayAllocator allocatorForValue(Object value) {
223-
if (value instanceof Integer) {
224-
return IntegerArrayStore.INTEGER_ARRAY_ALLOCATOR;
225-
} else if (value instanceof Long) {
226-
return LongArrayStore.LONG_ARRAY_ALLOCATOR;
227-
} else if (value instanceof Double) {
228-
return DoubleArrayStore.DOUBLE_ARRAY_ALLOCATOR;
229-
} else {
230-
return ObjectArrayStore.OBJECT_ARRAY_ALLOCATOR;
231-
}
232-
}
233-
234234
/** Class for allocating array stores and querying properties related to that. */
235235
public abstract static class ArrayAllocator {
236236

0 commit comments

Comments
 (0)