Bug 1511285 - Make 'mach clang-format' more efficient when outputting to stdout. r=ehsan, a=aryx
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Fri, 30 Nov 2018 14:04:46 +0200
changeset 505386 bf92aff5b93de1726b12207adc54dd138178250d
parent 505385 3acb179a17592b5f9a64cb30e0c6554b640d0a46
child 505387 138f65958545ae296c6742b9a13ca83f8310a0d8
child 505394 8e37b680ffbee7909c025c15ddb4c873419caf11
child 505462 91e1fe27cef95ba156878d94952d2052e023ef41
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, aryx
bugs1511285
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1511285 - Make 'mach clang-format' more efficient when outputting to stdout. r=ehsan, a=aryx Differential Revision: https://phabricator.services.mozilla.com/D13508
python/mozbuild/mozbuild/mach_commands.py
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -2811,32 +2811,27 @@ class StaticAnalysis(MachCommandBase):
                     path_list.append(f)
 
         return path_list
 
     def _run_clang_format_in_console(self, clang_format, paths, assume_filename):
         path_list = self._generate_path_list(assume_filename, False)
 
         if path_list == []:
-            # This means we are dealing with a third party so just return it's content
-            with open(paths[0], 'r') as fin:
-                sys.stdout.write(fin.read().decode('utf8'))
-                return 0
+            return 0
 
         # We use -assume-filename in order to better determine the path for
         # the .clang-format when it is ran outside of the repo, for example
         # by the extension hg-formatsource
         args = [clang_format, "-assume-filename={}".format(assume_filename[0])]
 
-        process = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+        process = subprocess.Popen(args, stdin=subprocess.PIPE)
         with open(paths[0], 'r') as fin:
             process.stdin.write(fin.read())
-            output = process.communicate()[0]
             process.stdin.close()
-            sys.stdout.write(output.decode('utf8'))
             return 0
 
     def _run_clang_format_path(self, clang_format, show, paths):
         # Run clang-format on files or directories directly
         from subprocess import check_output, CalledProcessError
 
         args = [clang_format, "-i"]