Use a list to buffer strings in _combine_logentries() and do
authorZac Medico <zmedico@gentoo.org>
Fri, 19 Oct 2007 19:27:06 +0000 (19:27 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 19 Oct 2007 19:27:06 +0000 (19:27 -0000)
a single concatenation at the end for better efficiency.

svn path=/main/trunk/; revision=8183

pym/portage/elog/__init__.py

index 4049b5521b494beaf3d674028ba67de7f54bf1c2..b9cc3f659920aaa8ec2d2d41bd9e01aa20e64cdd 100644 (file)
@@ -29,7 +29,7 @@ def _merge_logentries(a, b):
 
 def _combine_logentries(logentries):
        # generate a single string with all log messages
-       rValue = ""
+       rValue = []
        for phase in EBUILD_PHASES:
                if not phase in logentries:
                        continue
@@ -37,11 +37,11 @@ def _combine_logentries(logentries):
                for msgtype, msgcontent in logentries[phase]:
                        if previous_type != msgtype:
                                previous_type = msgtype
-                               rValue += "%s: %s\n" % (msgtype, phase)
+                               rValue.append("%s: %s\n" % (msgtype, phase))
                        for line in msgcontent:
-                               rValue += line
-                       rValue += "\n"
-       return rValue
+                               rValue.append(line)
+                       rValue.append("\n")
+       return "".join(rValue)
 
 _elog_atexit_handlers = []
 _preserve_logentries = {}