From: Zac Medico Date: Wed, 22 Aug 2012 21:12:31 +0000 (-0700) Subject: Optimize sys.std* flush code. X-Git-Tag: v2.2.0_alpha122 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5335ccb6558f22ddc926714dcba4443cc7333b6a;p=portage.git Optimize sys.std* flush code. --- diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py index d49c51f79..9ab03e24e 100644 --- a/pym/_emerge/EbuildMetadataPhase.py +++ b/pym/_emerge/EbuildMetadataPhase.py @@ -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 diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py index dfcf088bc..c7863c1ec 100644 --- a/pym/_emerge/SpawnProcess.py +++ b/pym/_emerge/SpawnProcess.py @@ -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: