Pulling requires out of often called methods.

While debugging this hairy situation, I had hooked require to try to
figure out sequencing. These requires were called thousands upon
thousands of times, creating a lot of noise and having no benefit
other than a possible savings of a few millisecond on an already slow
startup.

Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
Ryan Davis 2019-05-14 23:25:28 -07:00
parent 6adf1d2560
commit f5d35494d9
3 changed files with 3 additions and 3 deletions

View file

@ -2,6 +2,7 @@
# author: Christoph Hartmann
require 'inspec/dsl'
require 'inspec/dsl_shared'
require 'rspec/core/dsl'
module Inspec
#
@ -19,7 +20,6 @@ module Inspec
# @param [ResourcesDSL] resources_dsl which has all resources to attach
# @return [RuleContext] the inner context of rules
def self.rule_context(resources_dsl, profile_id)
require 'rspec/core/dsl'
Class.new(Inspec::Rule) do
include RSpec::Core::DSL
with_resource_dsl resources_dsl

View file

@ -5,6 +5,7 @@ require 'rubygems/version'
require 'rubygems/requirement'
require 'semverse'
require 'utils/spdx'
require 'erb'
module Inspec
# Extract metadata.rb information
@ -198,7 +199,6 @@ module Inspec
def self.from_yaml(ref, content, profile_id, logger = nil)
res = Metadata.new(ref, logger)
require 'erb'
res.params = YAML.load(ERB.new(content).result)
res.content = content
finalize(res, profile_id, {}, logger)

View file

@ -11,6 +11,7 @@ require 'inspec/metadata'
require 'inspec/config'
require 'inspec/dependencies/cache'
require 'inspec/dist'
require 'inspec/runner_rspec'
# spec requirements
module Inspec
@ -52,7 +53,6 @@ module Inspec
@cache = Inspec::Cache.new(@conf[:vendor_cache])
@test_collector = @conf.delete(:test_collector) || begin
require 'inspec/runner_rspec'
RunnerRspec.new(@conf)
end