From 0b79eabe7f4f5f841dd0503d899a6bd84c40c795 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 12 Aug 2020 14:15:48 -0700 Subject: Optimize requires for non-omnibus installs require is quite slow in Ruby and doing requires for things you've already required is also slow. We've used this simple hack in Chef to speed up our requires. In the omnibus installs we patch how rubygems works to make this somewhat pointless, but this will help non-omnibus installs Signed-off-by: Tim Smith --- lib/mixlib/shellout.rb | 4 ++-- lib/mixlib/shellout/helper.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb index 2b998ab..dc186a2 100644 --- a/lib/mixlib/shellout.rb +++ b/lib/mixlib/shellout.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require "etc" -require "tmpdir" +require "etc" unless defined?(Etc) +require "tmpdir" unless defined?(Dir.mktmpdir) require "fcntl" require_relative "shellout/exceptions" diff --git a/lib/mixlib/shellout/helper.rb b/lib/mixlib/shellout/helper.rb index ac63494..4543cf1 100644 --- a/lib/mixlib/shellout/helper.rb +++ b/lib/mixlib/shellout/helper.rb @@ -16,7 +16,7 @@ # limitations under the License. require_relative "../shellout" -require "chef-utils" +require "chef-utils" unless defined?(ChefUtils) require "chef-utils/dsl/default_paths" require "chef-utils/internal" -- cgit v1.2.1