MCPcopy Create free account
hub / github.com/grpc/grpc-java / discardAll

Method discardAll

api/src/main/java/io/grpc/Metadata.java:430–449  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 15

pickSubchannelMethod · 0.95
pickedMethod · 0.95
discardAllMethod · 0.95
discardAll_emptyMethod · 0.95
addStatusToTrailersMethod · 0.45
headersReadMethod · 0.45
setDeadlineMethod · 0.45
prepareHeadersMethod · 0.45
stripTransportDetailsMethod · 0.45
sendHeadersInternalMethod · 0.45
streamCreatedMethod · 0.45
toMetadataMethod · 0.45

Calls 7

isEmptyMethod · 0.95
bytesEqualMethod · 0.95
nameMethod · 0.95
valueMethod · 0.95
lenMethod · 0.95
asciiNameMethod · 0.80
fillMethod · 0.80

Tested by 2

discardAllMethod · 0.76
discardAll_emptyMethod · 0.76