From dfd45c0ac1a6e762dbc96b8817eebc853604104c Mon Sep 17 00:00:00 2001 From: Johan Engelen Date: Fri, 23 Oct 2020 16:17:55 +0200 Subject: [PATCH] std.stdio: move std.process import inside unittest This moves the std.process import inside the unittest. The import is not used elsewhere, and so is unnecessary for non-unittest builds. This greatly speeds up importing std.stdio. (In a simple testcase, more than 90% of the import time of std.stdio was spent on std.process) I've tried to keep whitespace changes to a minimum, while keeping the code readable. --- std/stdio.d | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/std/stdio.d b/std/stdio.d index 87900535d..c41469a39 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -1493,8 +1493,9 @@ Removes the lock over the specified file segment. } version (Posix) - static if (__traits(compiles, { import std.process : spawnProcess; })) @system unittest + { + static if (__traits(compiles, { import std.process : spawnProcess; })) { static import std.file; auto deleteme = testFilename(); @@ -1548,7 +1549,8 @@ Removes the lock over the specified file segment. g.unlock(); }); f.unlock(); - } + } // static if + } // unittest /**