mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
`normalize_path` is a pretty hot path, it's called many times per file in each gem. Since the platform isn't going to change from call to call, we can conditionally define `normalize_path` based on the value of `Gem.win_platform?`. https://github.com/rubygems/rubygems/commit/d5e61411f2
32 lines
519 B
Ruby
32 lines
519 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rbconfig"
|
|
|
|
module Gem
|
|
##
|
|
# An Array of Regexps that match windows Ruby platforms.
|
|
|
|
WIN_PATTERNS = [
|
|
/bccwin/i,
|
|
/cygwin/i,
|
|
/djgpp/i,
|
|
/mingw/i,
|
|
/mswin/i,
|
|
/wince/i,
|
|
].freeze
|
|
|
|
@@win_platform = nil
|
|
|
|
##
|
|
# Is this a windows platform?
|
|
|
|
def self.win_platform?
|
|
if @@win_platform.nil?
|
|
ruby_platform = RbConfig::CONFIG["host_os"]
|
|
@@win_platform = !WIN_PATTERNS.find {|r| ruby_platform =~ r }.nil?
|
|
end
|
|
|
|
@@win_platform
|
|
end
|
|
end
|