]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
gpo.py: avoid inefficient string concatenations
authorBjörn Jacke <bj@sernet.de>
Sun, 25 Aug 2019 21:05:31 +0000 (23:05 +0200)
committerBjoern Jacke <bjacke@samba.org>
Tue, 24 Sep 2019 12:22:44 +0000 (12:22 +0000)
Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/gpo.py

index 5a0258196c32b4a9167cc219c83306776643fc6a..047f91951e88c38eb93f1d5ac7a5995940e01861 100644 (file)
@@ -110,9 +110,7 @@ def parse_gplink(gplink):
 
 def encode_gplink(gplist):
     '''Encode an array of dn and options into gPLink string'''
-    ret = ''
-    for g in gplist:
-        ret += "[LDAP://%s;%d]" % (g['dn'], g['options'])
+    ret = "".join("[LDAP://%s;%d]" % (g['dn'], g['options']) for g in gplist)
     return ret
 
 
@@ -1079,9 +1077,8 @@ class cmd_backup(GPOCommand):
             entities = cmd_backup.generalize_xml_entities(self.outf, gpodir,
                                                           gpodir)
             import operator
-            ents = ''
-            for ent in sorted(entities.items(), key=operator.itemgetter(1)):
-                ents += '<!ENTITY {} "{}">\n'.format(ent[1].strip('&;'), ent[0])
+            ents = "".join('<!ENTITY {} "{}\n">'.format(ent[1].strip('&;'), ent[0]) \
+                             for ent in sorted(entities.items(), key=operator.itemgetter(1)))
 
             if ent_file:
                 with open(ent_file, 'w') as f: