Remove all values for the given key without returning them. This is a minor performance optimization if you do not need the previous values.
(Key<T> key)
| 428 | * optimization if you do not need the previous values. |
| 429 | */ |
| 430 | @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4691") |
| 431 | public <T> void discardAll(Key<T> key) { |
| 432 | if (isEmpty()) { |
| 433 | return; |
| 434 | } |
| 435 | int writeIdx = 0; |
| 436 | int readIdx = 0; |
| 437 | for (; readIdx < size; readIdx++) { |
| 438 | if (bytesEqual(key.asciiName(), name(readIdx))) { |
| 439 | continue; |
| 440 | } |
| 441 | name(writeIdx, name(readIdx)); |
| 442 | value(writeIdx, value(readIdx)); |
| 443 | writeIdx++; |
| 444 | } |
| 445 | int newSize = writeIdx; |
| 446 | // Multiply by two since namesAndValues is interleaved. |
| 447 | Arrays.fill(namesAndValues, writeIdx * 2, len(), null); |
| 448 | size = newSize; |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Serialize all the metadata entries. |