Bug 1673832 - Reduce allocations in merge_rrset. r=valentin,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D94954
This commit is contained in:
mcccs 2020-11-04 17:19:59 +00:00
parent fff64b3d07
commit e83823e865
2 changed files with 9 additions and 10 deletions

View File

@ -20,14 +20,13 @@ static already_AddRefed<AddrInfo> merge_rrset(AddrInfo* rrto,
bool isIPv6 = rrfrom->Addresses().Length() > 0 &&
rrfrom->Addresses()[0].raw.family == PR_AF_INET6;
nsTArray<NetAddr> addresses = rrto->Addresses().Clone();
for (const auto& addr : rrfrom->Addresses()) {
if (isIPv6) {
// rrfrom has IPv6 so it should be first
addresses.InsertElementAt(0, addr);
} else {
addresses.AppendElement(addr);
}
nsTArray<NetAddr> addresses;
if (isIPv6) {
addresses = rrfrom->Addresses().Clone();
addresses.AppendElements(rrto->Addresses());
} else {
addresses = rrto->Addresses().Clone();
addresses.AppendElements(rrfrom->Addresses());
}
auto builder = rrto->Build();
builder.SetAddresses(std::move(addresses));

View File

@ -13,6 +13,8 @@ const dns = Cc["@mozilla.org/network/dns-service;1"].getService(
trr_test_setup();
registerCleanupFunction(async () => {
Services.prefs.clearUserPref("network.connectivity-service.nat64-prefix");
override.clearOverrides();
trr_clear_prefs();
});
@ -114,6 +116,4 @@ add_task(async function test_add_nat64_prefix_to_trr() {
);
await trrServer.stop();
override.clearOverrides();
});