HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/ruby/vendor_ruby/bootsnap/load_path_cache/realpath_cache.rb
# frozen_string_literal: true

module Bootsnap
  module LoadPathCache
    class RealpathCache
      def initialize
        @cache = Hash.new { |h, k| h[k] = realpath(*k) }
      end

      def call(*key)
        @cache[key]
      end

      private

      def realpath(caller_location, path)
        base = File.dirname(caller_location)
        abspath = File.expand_path(path, base).freeze
        find_file(abspath)
      end

      def find_file(name)
        return File.realpath(name).freeze if File.exist?(name)
        CACHED_EXTENSIONS.each do |ext|
          filename = "#{name}#{ext}"
          return File.realpath(filename).freeze if File.exist?(filename)
        end
        name
      end
    end
  end
end