Rename getShrinkedBackingArray to getMinimized*
"Shrinked" should actually be "shrunk" or "shrunken"; in any case "minimized" is simpler and possibly more accurate (it's the minimum size required to hold the values). Test: atest Change-Id: If787d3f3d6e1046338d4e89ed924bce183e74bd6
This commit is contained in:
parent
2d78124348
commit
dfb159289b
5 changed files with 6 additions and 7 deletions
|
|
@ -34,8 +34,7 @@ import com.android.net.module.util.GrowingIntArray;
|
|||
* queue.forEach(netId, callbackId -> { [...] });
|
||||
* queue.addCallback(netId, callbackId);
|
||||
* [...]
|
||||
* queue.shrinkToLength();
|
||||
* storedCallbacks = queue.getBackingArray();
|
||||
* storedCallbacks = queue.getMinimizedBackingArray();
|
||||
* </pre>
|
||||
*
|
||||
* <p>This class is not thread-safe.
|
||||
|
|
|
|||
|
|
@ -7976,7 +7976,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
// Instead of shrinking the queue, possibly reallocating, the NRI could keep the array
|
||||
// and length in memory for future adds, but this saves memory by avoiding the cost
|
||||
// of an extra member and of unused array length (there are often hundreds of NRIs).
|
||||
mQueuedCallbacks = queue.getShrinkedBackingArray();
|
||||
mQueuedCallbacks = queue.getMinimizedBackingArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ public class GrowingIntArray {
|
|||
* stop using this instance of {@link GrowingIntArray} if they use the array returned by this
|
||||
* method.
|
||||
*/
|
||||
public int[] getShrinkedBackingArray() {
|
||||
public int[] getMinimizedBackingArray() {
|
||||
shrinkToLength();
|
||||
return mValues;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,12 +109,12 @@ class GrowingIntArrayTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun testGetShrinkedBackingArray() {
|
||||
fun testGetMinimizedBackingArray() {
|
||||
val array = GrowingIntArray(10)
|
||||
array.add(-1)
|
||||
array.add(2)
|
||||
|
||||
assertContentEquals(intArrayOf(-1, 2), array.shrinkedBackingArray)
|
||||
assertContentEquals(intArrayOf(-1, 2), array.minimizedBackingArray)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class CallbackQueueTest {
|
|||
addCallback(TEST_NETID_1, CALLBACK_AVAILABLE)
|
||||
addCallback(TEST_NETID_2, CALLBACK_AVAILABLE)
|
||||
}
|
||||
val queue2 = CallbackQueue(queue1.shrinkedBackingArray)
|
||||
val queue2 = CallbackQueue(queue1.minimizedBackingArray)
|
||||
assertQueueEquals(listOf(
|
||||
TEST_NETID_1 to CALLBACK_AVAILABLE,
|
||||
TEST_NETID_2 to CALLBACK_AVAILABLE
|
||||
|
|
|
|||
Loading…
Reference in a new issue