Skip to content

Commit

Permalink
Merge pull request #4010 from rubygems/lazily_load_default_gems
Browse files Browse the repository at this point in the history
Lazily load `time`, `cgi`, and `zlib`

(cherry picked from commit 0af1449)
  • Loading branch information
deivid-rodriguez committed Dec 7, 2020
1 parent 1e6a194 commit 485650b
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/rubygems/indexer.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'rubygems'
require 'rubygems/package'
require 'time'
require 'tmpdir'

##
Expand Down
3 changes: 2 additions & 1 deletion lib/rubygems/package.rb
Expand Up @@ -44,7 +44,6 @@
require "rubygems"
require 'rubygems/security'
require 'rubygems/user_interaction'
require 'zlib'

class Gem::Package
include Gem::UserInteraction
Expand Down Expand Up @@ -186,6 +185,8 @@ def self.raw_spec(path, security_policy = nil)
# Creates a new package that will read or write to the file +gem+.

def initialize(gem, security_policy) # :notnew:
require 'zlib'

@gem = gem

@build_time = Gem.source_date_epoch
Expand Down
1 change: 0 additions & 1 deletion lib/rubygems/remote_fetcher.rb
Expand Up @@ -78,7 +78,6 @@ def self.fetcher
def initialize(proxy=nil, dns=nil, headers={})
require 'net/http'
require 'stringio'
require 'time'
require 'uri'

Socket.do_not_reverse_lookup = true
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/request.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
require 'net/http'
require 'time'
require 'rubygems/user_interaction'

class Gem::Request
Expand Down Expand Up @@ -143,6 +142,7 @@ def fetch
request.add_field 'Keep-Alive', '30'

if @last_modified
require 'time'
request.add_field 'If-Modified-Since', @last_modified.httpdate
end

Expand Down
3 changes: 2 additions & 1 deletion lib/rubygems/uri_formatter.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require 'cgi'

##
# The UriFormatter handles URIs from user-input and escaping.
Expand All @@ -18,6 +17,8 @@ class Gem::UriFormatter
# Creates a new URI formatter for +uri+.

def initialize(uri)
require 'cgi'

@uri = uri
end

Expand Down
1 change: 0 additions & 1 deletion util/create_certs.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
require 'openssl'
require 'time'

class CertificateBuilder
attr_reader :start
Expand Down

0 comments on commit 485650b

Please sign in to comment.