]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
scripting: avoid inefficient string redefinition
authorBjörn Jacke <bj@sernet.de>
Sun, 25 Aug 2019 21:10:19 +0000 (23:10 +0200)
committerBjoern Jacke <bjacke@samba.org>
Tue, 24 Sep 2019 12:22:45 +0000 (12:22 +0000)
Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
source4/scripting/bin/samba_upgradeprovision
source4/scripting/devel/config_base

index 6d484b750daf3d9f5908c6f6375df6b1819ad432..6f4de4ee255f4d995425291d856b45658d7bb398 100755 (executable)
@@ -1063,14 +1063,10 @@ def reload_full_schema(samdb, names):
     schemadn = str(names.schemadn)
     current = samdb.search(expression="objectClass=*", base=schemadn,
                                 scope=SCOPE_SUBTREE)
-    schema_ldif = ""
-    prefixmap_data = ""
 
-    for ent in current:
-        schema_ldif += samdb.write_ldif(ent, ldb.CHANGETYPE_NONE)
+    schema_ldif = "".join(samdb.write_ldif(ent, ldb.CHANGETYPE_NONE) for ent in current)
 
-    prefixmap_data = open(setup_path("prefixMap.txt"), 'rb').read()
-    prefixmap_data = b64encode(prefixmap_data).decode('utf8')
+    prefixmap_data = b64encode(open(setup_path("prefixMap.txt"), 'rb').read()).decode('utf8')
 
     # We don't actually add this ldif, just parse it
     prefixmap_ldif = "dn: %s\nprefixMap:: %s\n\n" % (schemadn, prefixmap_data)
index 1aa436de1a5b77c145574b8b286f6866fc6e419b..f593f2f627d6de64d215dcb60087d41b95bd87d7 100755 (executable)
@@ -30,11 +30,10 @@ if not os.path.isdir(config_dir):
 if not os.path.isfile(config_file):
     open(config_file, mode='w').close()
 
-options = " --configfile=${PREFIX}/etc/smb.conf"
+options = (
+          " --configfile=${PREFIX}/etc/smb.conf"
+          "".join(" --option=%s=%s" % (v.replace(" ",""), vars[v]) for v in vars)
+         ).replace("${PREFIX}", prefix)
 
-for v in vars:
-    options += " --option=%s=%s" % (v.replace(" ",""), vars[v])
-
-options = options.replace("${PREFIX}", prefix)
 
 print(options)