]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
No need to keep a bunch of string in memory after having printed them.
authorMiod Vallat <miod.vallat@powerdns.com>
Mon, 11 Aug 2025 09:59:21 +0000 (11:59 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Mon, 11 Aug 2025 11:10:05 +0000 (13:10 +0200)
And this allows the serial increase block to do less work.

Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/pdnsutil.cc

index 98359e75a7a9c24e6406def48a54eafb487713f1..2d06ff02c851d1e07107adc51f2f73e35783f029 100644 (file)
@@ -2076,8 +2076,12 @@ static int editZone(const ZoneName &zone, const PDNSColors& col)
         }
       }
       cout<<"Detected the following changes:"<<endl;
-      for(const auto& change : changed) {
+      for(auto& change : changed) {
         cout<<change.second;
+        // After this display, we only need the keys of `changed' to know which
+        // records need updates, but not the text representation anymore (we
+        // will use the contents of `post' for that purpose).
+        change.second.clear();
       }
       // If the SOA record has not been modified, ask the user if they want to
       // update the serial number.
@@ -2100,10 +2104,7 @@ static int editZone(const ZoneName &zone, const PDNSColors& col)
         {
           DNSRecord rec;
           if (increaseZoneSerial(B, dsk, info, post, col, rec)) {
-            ostringstream str;
-            str << col.green() << "+" << rec.d_name << " " << rec.d_ttl<< " IN " <<DNSRecordContent::NumberToType(rec.d_type) << " " <<rec.getContent()->getZoneRepresentation(true) << col.rst() <<endl;
-
-            changed[{rec.d_name, rec.d_type}]+=str.str();
+            changed[{rec.d_name, rec.d_type}]="";
             state = ASKAPPLY;
           }
           else {
@@ -2162,7 +2163,8 @@ static int editZone(const ZoneName &zone, const PDNSColors& col)
             resrec.domain_id = info.id;
             records.push_back(std::move(resrec));
           }
-          info.backend->replaceRRSet(info.id, change.first.first, QType(change.first.second), records);
+          auto [qname, qtype] = change.first;
+          info.backend->replaceRRSet(info.id, qname, QType(qtype), records);
         }
       }
       post.clear();