From eec1ce6510d036130b5c9f76f6032a43993f11a6 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 12 Feb 2026 11:08:58 +0100 Subject: [PATCH] Eagerload code While I understand that `autoload` is convenient, it's not good for production performance and it cause the code to be loaded the first time the constant is referenced, in many case that means as part of the first request, and cause latency spikes on deploy. It's better to immediately require all the code, especially since phonelib is relatively small. --- lib/phonelib.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/phonelib.rb b/lib/phonelib.rb index f591773..086ed4f 100644 --- a/lib/phonelib.rb +++ b/lib/phonelib.rb @@ -3,12 +3,12 @@ # main Phonelib module definition module Phonelib # load phonelib classes/modules - autoload :Core, 'phonelib/core' - autoload :Phone, 'phonelib/phone' - autoload :PhoneFormatter, 'phonelib/phone_formatter' - autoload :PhoneAnalyzer, 'phonelib/phone_analyzer' - autoload :PhoneAnalyzerHelper, 'phonelib/phone_analyzer_helper' - autoload :PhoneExtendedData, 'phonelib/phone_extended_data' + require 'phonelib/core' + require 'phonelib/phone_formatter' + require 'phonelib/phone_analyzer_helper' + require 'phonelib/phone_analyzer' + require 'phonelib/phone_extended_data' + require 'phonelib/phone' extend Core end