From: Björn Jacke Date: Sun, 25 Aug 2019 21:10:19 +0000 (+0200) Subject: scripting: avoid inefficient string redefinition X-Git-Tag: talloc-2.3.1~714 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c7fa030aecd1de5ed32e2509ecd83828aa42c1a3;p=thirdparty%2Fsamba.git scripting: avoid inefficient string redefinition Signed-off-by: Bjoern Jacke Reviewed-by: Matthias Dieter Wallnöfer --- diff --git a/source4/scripting/bin/samba_upgradeprovision b/source4/scripting/bin/samba_upgradeprovision index 6d484b750da..6f4de4ee255 100755 --- a/source4/scripting/bin/samba_upgradeprovision +++ b/source4/scripting/bin/samba_upgradeprovision @@ -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) diff --git a/source4/scripting/devel/config_base b/source4/scripting/devel/config_base index 1aa436de1a5..f593f2f627d 100755 --- a/source4/scripting/devel/config_base +++ b/source4/scripting/devel/config_base @@ -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)