Skip to content

Commit

Permalink
Changed IPAddress.parse() to improve speed (see new wiki benchmark page)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemonk committed May 24, 2011
1 parent 96aaf68 commit 10c9350
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ipaddress.rb
Expand Up @@ -43,8 +43,12 @@ def IPAddress::parse(str)
case str
when /:.+\./
IPAddress::IPv6::Mapped.new(str)
when /\./
IPAddress::IPv4.new(str)
when /:/
IPAddress::IPv6.new(str)
else
IPAddress::IPv4.new(str) rescue IPAddress::IPv6.new(str)
raise ArgumentError, "Unknown IP Address #{str}"
end
end

Expand Down

0 comments on commit 10c9350

Please sign in to comment.