From 5335ccb6558f22ddc926714dcba4443cc7333b6a Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 22 Aug 2012 14:12:31 -0700 Subject: [PATCH] Optimize sys.std* flush code. --- pym/_emerge/EbuildMetadataPhase.py | 5 +++-- pym/_emerge/SpawnProcess.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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: -- 2.26.2