Skip to content

Commit 09c0289

Browse files
Autoload OpenSSL
Profiling laoding faker showed that by autoloading OpenSSL, we could improve Faker's loading time by about 17%. A lot of the time is spent on set_default_paths. Given that OpenSSL is only used in a very limited way and only by 3 generators, this would speed up the library for most users. Co-Authored-By: Thiago Araujo <thd.araujo@gmail.com>
1 parent a832b60 commit 09c0289

5 files changed

Lines changed: 1 addition & 14 deletions

File tree

Gemfile.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ GEM
9393

9494
PLATFORMS
9595
arm64-darwin-22
96-
arm64-darwin-24
9796
x86_64-linux
9897

9998
DEPENDENCIES

lib/faker.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
require 'psych'
66
require 'i18n'
77

8-
if ENV['AUTOLOAD'] == '1'
9-
autoload(:OpenSSL, 'openssl')
10-
end
8+
autoload(:OpenSSL, 'openssl')
119

1210
Dir.glob(File.join(mydir, 'helpers', '*.rb')).each { |file| require file }
1311

lib/faker/blockchain/bitcoin.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# frozen_string_literal: true
22

3-
if ENV['AUTOLOAD'] != '1'
4-
require 'openssl'
5-
end
63
require 'securerandom'
74

85
module Faker

lib/faker/blockchain/tezos.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# frozen_string_literal: true
22

3-
if ENV['AUTOLOAD'] != '1'
4-
require 'openssl'
5-
end
63
require 'securerandom'
74

85
module Faker

lib/faker/default/crypto.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# frozen_string_literal: true
22

3-
if ENV['AUTOLOAD'] != '1'
4-
require 'openssl'
5-
end
6-
73
module Faker
84
class Crypto < Base
95
class << self

0 commit comments

Comments
 (0)