From d313ea88437dcb2bac891647296ae15453987509 Mon Sep 17 00:00:00 2001 From: Maciek Zielinski Date: Sat, 5 Aug 2017 14:54:36 +1000 Subject: [PATCH 1/2] Load solc module in lazy fashion. Saves up to 2s when compilation is not required. --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5b3bba2..69970f1 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,5 @@ var Profiler = require("./profiler"); var OS = require("os"); -var solc = require("solc"); // Clean up after solc. var listeners = process.listeners("uncaughtException"); @@ -43,6 +42,9 @@ var compile = function(sources, options, callback) { "contracts_directory" ]); + // Load solc module only when compilation is actually required. + var solc = require("solc"); + // Ensure sources have operating system independent paths // i.e., convert backslashes to forward slashes; things like C: are left intact. var operatingSystemIndependentSources = {}; From fccb648a8ee92f1a4d1e74f925135d1bd883679c Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Tue, 24 Oct 2017 12:43:14 -0400 Subject: [PATCH 2/2] Ensure solc cleanup happens after import --- index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 69970f1..2cdfea7 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,6 @@ var Profiler = require("./profiler"); var OS = require("os"); -// Clean up after solc. -var listeners = process.listeners("uncaughtException"); -var solc_listener = listeners[listeners.length - 1]; - -if (solc_listener) { - process.removeListener("uncaughtException", solc_listener); -} - var path = require("path"); var fs = require("fs"); var async = require("async"); @@ -44,6 +36,14 @@ var compile = function(sources, options, callback) { // Load solc module only when compilation is actually required. var solc = require("solc"); + // Clean up after solc. + var listeners = process.listeners("uncaughtException"); + var solc_listener = listeners[listeners.length - 1]; + + if (solc_listener) { + process.removeListener("uncaughtException", solc_listener); + } + // Ensure sources have operating system independent paths // i.e., convert backslashes to forward slashes; things like C: are left intact.