File better-string-replacement-performance.diff of Package cobbler

diff --git a/cobbler/templar.py b/cobbler/templar.py
index aeb161214..ab2beb46f 100644
--- a/cobbler/templar.py
+++ b/cobbler/templar.py
@@ -24,6 +24,7 @@
 
 from builtins import str
 from builtins import object
+import re
 import Cheetah
 import functools
 import os
@@ -139,9 +140,11 @@ def render(self, data_input, search_table, out_path, subject=None, template_type
             repstr = server
         search_table["http_server"] = repstr
 
-        for x in list(search_table.keys()):
-            if type(x) == str:
-                data_out = data_out.replace("@@%s@@" % str(x), str(search_table[str(x)]))
+        # string replacements for @@xyz@@ in data_out with prior regex lookups of keys
+        regex = r"@@[a-zA-Z]*@@"
+        matches = re.finditer(regex, data_out, re.MULTILINE)
+        for matchNum, match in enumerate(matches, start=1):
+            data_out = data_out.replace(match.group(), search_table[str(match.group()).strip("@@")])
 
         # remove leading newlines which apparently breaks AutoYAST ?
         if data_out.startswith("\n"):
openSUSE Build Service is sponsored by