BpfMap.java - remove getRawValue()
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6903a29773ee4782c0f2ae64561e1c0fdcba618f
diff --git a/staticlibs/device/com/android/net/module/util/BpfMap.java b/staticlibs/device/com/android/net/module/util/BpfMap.java
index 9df2b03..b3451c1 100644
--- a/staticlibs/device/com/android/net/module/util/BpfMap.java
+++ b/staticlibs/device/com/android/net/module/util/BpfMap.java
@@ -233,30 +233,23 @@
public boolean containsKey(@NonNull K key) throws ErrnoException {
Objects.requireNonNull(key);
- final byte[] rawValue = getRawValue(key.writeToBytes());
- return rawValue != null;
+ byte[] rawValue = new byte[mValueSize];
+ return nativeFindMapEntry(mMapFd.getFd(), key.writeToBytes(), rawValue);
}
/** Retrieve a value from the map. Return null if there is no such key. */
@Override
public V getValue(@NonNull K key) throws ErrnoException {
Objects.requireNonNull(key);
- final byte[] rawValue = getRawValue(key.writeToBytes());
- if (rawValue == null) return null;
+ byte[] rawValue = new byte[mValueSize];
+ if (!nativeFindMapEntry(mMapFd.getFd(), key.writeToBytes(), rawValue)) return null;
final ByteBuffer buffer = ByteBuffer.wrap(rawValue);
buffer.order(ByteOrder.nativeOrder());
return Struct.parse(mValueClass, buffer);
}
- private byte[] getRawValue(final byte[] key) throws ErrnoException {
- byte[] value = new byte[mValueSize];
- if (nativeFindMapEntry(mMapFd.getFd(), key, value)) return value;
-
- return null;
- }
-
/**
* Iterate through the map and handle each key -> value retrieved base on the given BiConsumer.
* The given BiConsumer may to delete the passed-in entry, but is not allowed to perform any