Optimize sys.std* flush code. v2.2.0_alpha122
authorZac Medico <zmedico@gentoo.org>
Wed, 22 Aug 2012 21:12:31 +0000 (14:12 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 22 Aug 2012 21:12:31 +0000 (14:12 -0700)
pym/_emerge/EbuildMetadataPhase.py
pym/_emerge/SpawnProcess.py

index d49c51f7906786d0e5bea9b83e22864c8a6aaa93..9ab03e24e81fdbce94e669b7090c00213d709ae3 100644 (file)
@@ -78,11 +78,12 @@ class EbuildMetadataPhase(SubProcess):
                fd_pipes.setdefault(2, sys.__stderr__.fileno())
 
                # flush any pending output
+               stdout_filenos = (sys.__stdout__.fileno(), sys.__stderr__.fileno())
                for fd in fd_pipes.values():
-                       if fd == sys.__stdout__.fileno():
+                       if fd in stdout_filenos:
                                sys.__stdout__.flush()
-                       if fd == sys.__stderr__.fileno():
                                sys.__stderr__.flush()
+                               break
 
                self._files = self._files_dict()
                files = self._files
index dfcf088bcfbceb177076a0ad10ba253c6ffa1ec7..c7863c1ec6dc33ca1cc6bf0e13576ae2d2d8caf3 100644 (file)
@@ -67,11 +67,12 @@ class SpawnProcess(SubProcess):
                fd_pipes.setdefault(2, sys.__stderr__.fileno())
 
                # flush any pending output
+               stdout_filenos = (sys.__stdout__.fileno(), sys.__stderr__.fileno())
                for fd in fd_pipes.values():
-                       if fd == sys.__stdout__.fileno():
+                       if fd in stdout_filenos:
                                sys.__stdout__.flush()
-                       if fd == sys.__stderr__.fileno():
                                sys.__stderr__.flush()
+                               break
 
                if logfile is not None: