Change mIfaceMatch to precompiled Pattern

See ag/33952010.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I29694e9b60a24f21290f903760dc96cb679b46e2
This commit is contained in:
Patrick Rohr 2025-06-11 13:14:54 -07:00
commit d909dadc8d

View file

@ -131,7 +131,7 @@ public class EthernetTracker {
* Use shouldTrackInterface to check if a interface name is a valid ethernet interface (this
* includes test interfaces if setIncludeTestInterfaces is set to true).
*/
private final String mIfaceMatch;
private final Pattern mIfaceMatch;
/**
* Track test interfaces if true, don't track otherwise.
@ -311,7 +311,7 @@ public class EthernetTracker {
ifaceMatchRegex = "eth\\d+";
}
}
mIfaceMatch = ifaceMatchRegex;
mIfaceMatch = Pattern.compile(ifaceMatchRegex);
// Read default Ethernet interface configuration from resources
final String[] interfaceConfigs = mDeps.getInterfaceConfigFromResource(context);
@ -829,7 +829,7 @@ public class EthernetTracker {
}
private boolean shouldTrackInterface(String iface) {
return iface.matches(mIfaceMatch) || isValidTestInterface(iface);
return mIfaceMatch.matcher(iface).matches() || isValidTestInterface(iface);
}
/**